Algorithm/Programmers

[Python] 문자열 다루기 기본

느낌표 공장장 2021. 4. 16. 23:18
def solution(s):
    return s.isdigit() and len(s) == 4 or len(s) == 6

isdigit 함수를 이용한다.

isdigit 함수는 해당 변수에 할당된 문자열이 숫자로만 되어있으면 True, 아니면 False를 반환한다.