【发布时间】:2017-11-03 08:33:29
【问题描述】:
我不知道为什么在“excpet”上出现语法错误。在我看来一切都很好!这是我的代码:
def length():
gameLength = int(input("How many words do you want to play? You can chose anywhere from 1-40: "))
global gameLength
if gameLength <= 40 and gameLength >= 1:
quit
else:
int(input("Please choose a number between 1 & 40 "))
except ValueError = True:
int(input("Please choose a number between 1 & 40 "))
return gameLength
【问题讨论】:
-
可能是因为你打错了'except'?
-
我很惊讶你只收到一个错误那里。使用您展示的代码,正如您展示的那样,您应该首先遇到许多其他错误。假设这是 Python 当然(不要忘记语言标签!)。
-
另外,在发布有关错误的问题时,请将实际的错误输出复制粘贴到问题中。作为文本,完整、完整且未经编辑。
-
最后,请read more about exceptions,因为你没有正确使用它。
标签: python syntax compiler-errors except