1번

from collections import Counter
def solution(s):
    myCounter =  Counter([str.lower(i) for i in s])
    answer =False
    if myCounter['p'] == myCounter['y']: answer =True
    return answer

2번

def numPY(s):
    # 함수를 완성하세요
    return s.lower().count('p') == s.lower().count('y')

lower 메소드와 count 메소드를 활용하면 더욱 간단하게 풀이 가능, 기억하고 있어야 함.

+ Recent posts