[알고리즘]기초1-문자열 내 p와 y의 개수

sunnwave·2022년 5월 25일
0

알고리즘

목록 보기
6/47
post-thumbnail

문자열 내 p와 y의 개수

https://programmers.co.kr/learn/courses/30/lessons/12916

def solution(s):
    answer = True
    p_count=s.count('p')+s.count('P')
    y_count=s.count('y')+s.count('Y')
    
    if p_count != y_count:
        answer=False

    return answer
def solution(s):
    answer = True
    lower_s=s.lower()
    p_count=lower_s.count('p')
    y_count=lower_s.count('y')
    
    answer=bool(p_count==y_count)
    
    return answer
profile
조구마한 개발 기록 블로그

0개의 댓글

관련 채용 정보