프로그래머스/Lv. 1
22. 문자열 다루기 기본
Seohyeong Lee
2024. 7. 12. 20:33
유형 : 구현
풀이 시간 : 5분
def solution(s):
if len(s) != 4 and len(s) != 6:
return False
answer = True
numlist = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
slist = list(s)
for ch in slist:
if ch not in numlist:
answer = False
return answer
return answer
길이가 4 또는 6인지도 체크해야 하는데, 조건을 제대로 안 봤다.
주어진 조건 잘 체크하기