python 문자열 다루기 기본

quokka·2021년 3월 7일
0

코딩테스트

목록 보기
13/63

isdigit(): 문자열이 모두 숫자여야 isdigit()이 True임

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

다른사람의 풀이

def solution(s):
    return s.isdigit() and len(s) in (4,6)
profile
iOS를 공부하는 개발자입니다~ㅎㅎ

0개의 댓글

관련 채용 정보