문자열이 숫자인지 파악하는 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
'프로그래머스 풀이' 카테고리의 다른 글
[프로그래머스] 약수의 합 풀이 (파이썬) (0) | 2022.04.26 |
---|---|
[프로그래머스] 수박수박수박수박수박수? 풀이 (python) (0) | 2022.04.11 |
[프로그래머스] 문자열 내림차순으로 배치하기 (파이썬) (0) | 2022.02.18 |
[프로그래머스] Lv.1 문자열 내 p와 y의 개수 (파이썬) (0) | 2022.02.17 |
[프로그래머스] Lv.1 문자열 내 마음대로 정렬하기 (파이썬) (0) | 2022.02.16 |