프로그래머스 풀이

[프로그래머스] Lv.1 문자열 다루기 기본 (파이썬)

ag2개발자 2022. 2. 25. 01:47

문자열이 숫자인지 파악하는 isdigit()함수를 사용하고 길이가 4 또는 6이 아닌 것을 파악해주면 된다.

 

def solution(s):
    answer = True
    if s.isdigit() == False:
        answer = False
    if len(s)!=4 and len(s)!=6:
        answer = False
    return answer