[프로그래머스] 문자열 내 p와 y의 갯수

Jin Lee·2022년 5월 15일
0

프로그래머스 Lv.1

목록 보기
4/32
post-thumbnail

문제 링크

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

문제 설명

  • 단순 구현 문제

코드

def solution(s):
    s_lower = s.lower()
    
    p_count = 0
    y_count = 0
    for string in s_lower:
        if string == 'p':
            p_count = p_count + 1
        elif string == 'y':
            y_count = y_count + 1
    
    if p_count == y_count:
        return True
    else:
        return False
profile
깃허브 : https://github.com/jinlee9270

0개의 댓글