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
I don't know where it's wrong.
python
It's Python, but it doesn't have an indent. I think the person who answers will read it if you post the code at least indent TT
For reference, in the case of vcode, alt + shift + F
is automatically returned according to the indentation format.
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
From here, the if text[7]
line has a if not
phrase in front of it, so it should be indented in the next line, but it is not indented.
© 2024 OneMinuteCode. All rights reserved.