강의로 돌아가기
rhj080471@gmail.com

파이썬 답 공유

.

작성중인 코드―solution.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def solution(s):
    alpha = 'abcdefghijklmnopqrstuvwxyz'
    FalseNum = 0
    if len(s) == 4 or len(s) == 6:
        for i in range(len(s)):
            if s[i].lower() in alpha:
                FalseNum += 1
            else:
                pass
        if FalseNum != 0:
            return False
        else: 
            return True
    else:
        return False

solution('1a1114')

1 개의 답변
DongWoo Ro

def solution(s):
try:
if not (len(s)4 or len(s)6):
return False
int(s)
except:
return False
return True

답변 쓰기
이 입력폼은 마크다운 문법을 지원합니다. 마크다운 가이드 를 참고하세요.