프로그래머스. 문자열 내 p와 y의 개수 파이썬 풀이

minan·2021년 6월 24일
0

프로그래머스

목록 보기
49/92

프로그래머스. 연습문제. Level 1. 문자열 내 p와 y의 개수 파이썬 풀이

문제링크 https://programmers.co.kr/learn/courses/30/lessons/12916

def solution(s):
    answer = True
    
    # p와 P의 개수
    p_count = s.count('p')
    p_count += s.count('P')
	
    # y와 Y의 개수
    y_count = s.count('y')
    y_count += s.count('Y')

	# 개수가 같으면 True 다르면 False 리턴
    return True if p_count == y_count else False
profile
https://github.com/minhaaan

0개의 댓글