IndentationError 질문있습니다.
조회수 679회
def isPhoneNumber(text):
if len(text) != 12:
return False
for i in range(0,3):
if not text[i].isdecimal():
return False
if text[3] != '-':
return False
for i in range(4,7):
if not text[i].isdecimal():
return False
if not text[i].isdecimal():
if text[7] != '-':
return False
for i in range(8,12):
if not text[i].isdeciaml():
return False
return True
print('415-555-4242 is a phone Number')
print(isPhoneNumber('415-555-4242'))
print('Moshi moshi is a phone number')
print(isPhoneNumber('Moshi moshi'))
if text[7] != '-':
^
IndentationError: expected an indented block
틀린곳을 잘모르겠습니다..
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
2 답변
-
파이썬인데 인덴트가 안들어가있네요... 적어도 indent정도는 해서 코드를 올려주셔야 답변을 달아주시는분이 읽어주시지 않을까요 ㅠㅠ
참고로 vscode의 경우
alt + shift + F
를 통해 자동으로 들여쓰기 서식에 맞게 반환을 해줍니다.https://stackoverflow.com/questions/29973357/how-do-you-format-code-in-visual-studio-code-vscode
-
(•́ ✖ •̀)
알 수 없는 사용자
-
-
def isPhoneNumber(text): if len(text) != 12: return False for i in range(0,3): if not text[i].isdecimal(): return False if text[3] != '-': return False for i in range(4,7): if not text[i].isdecimal(): return False if not text[i].isdecimal(): if text[7] != '-': return False for i in range(8,12): if not text[i].isdeciaml(): return False return True
return False if not text[i].isdecimal(): if text[7] != '-': return False
여기서 보면,
if text[7]
라인 앞 라인에서if not
구문이 있어서 그 다음 줄에서 들여쓰기가 되어야 하는데, 들여쓰기가 되어 있지 않습니다.
댓글 입력