while True:
try:
a = float(input("Enter a number for how long the break between words should be:")
except ValueError:
print("YOu haven't entered a number")
在我执行它之后:
File "main.py", line 7 except ValueError: ^ SyntaxError: invalid syntax
为什么会出现此错误?
此行末尾缺少一个右括号:
a = float(input("Enter a number for how long the break between words should be:")
您在第3行缺少右括号,您的代码应该是:
while True:
try:
a = float(input("Enter a number for how long the break between words should be:"))
except ValueError:
print("You haven't entered a number")