문제링크: 문자열 다루기 기본
✍🏻 Information
| content | |
|---|---|
| 언어 | python |
| 난이도 | ⭐️+0.5 |
| 풀이시간 | 5분 |
| 제출횟수 | 3 |
| 인터넷검색유무 | yes |
🍒 My Code
def solution(s):
answer = True
if len(s)!=4 and len(s)!=6:
answer = False
else:
answer = s.isdigit()
return answer
💡 What I learned
str.isdigit(): 문자열이 숫자로만 이루어져있는 경우 True 반환. 음수기호 -나 소수 .은 문자로 취급.str.isdecimal(): 데이터가 int 타입으로 변환이 가능한 숫자인 경우 True 반환str.isalpha(): 문자열이 문자로만 이루어져있는 경우 True 반환