jeeyeonLIM / coding_test

Let's practice the coding test!
1 stars 0 forks source link

[연습문제]문자열 내 p와 y의 개수 #44

Open jeeyeonLIM opened 3 years ago

jeeyeonLIM commented 3 years ago

문제 설명

제한사항

입출력 예

s answer
pPoooyY true
Pyy false

입출력 예 설명

입출력 예 #1

입출력 예 #2

jeeyeonLIM commented 3 years ago

작성코드

def solution(s):
    answer = True
    p=0
    y=0
    for i in s.lower():
        if i =="p":
            p+=1
        elif i =="y":
            y+=1
    if p == y:
        return True
    else:
        return False

-오늘의 코드는 의식의 흐름대로 작성하였다.

jeeyeonLIM commented 3 years ago

다른사람의 풀이 !

def solution(s):
    return s.lower().count('p') == s.lower().count('y')

의문사항 ⚡