【发布时间】:2019-09-21 19:24:08
【问题描述】:
下面是我的代码,错误在第 4 行,“except”给出了一个语法错误...(这是一个调试和错误捕获分配。我看不出它有什么问题)
while True:
try:
userInputOne = input(int("How much time in hours a week, do you spend practicing? ")
except TypeError:
print("Oops! Practice time must be rounded to the nearest integer. It also needs to be a numerical value! ")
break
else:
userInputTwo = str(input"How good to do want to be? Enter 'very good', 'good', mediocre, 'not good' ")
if userInputTwo not in ('very good', 'good', 'mediocre', 'not good'):
print("Please use one of the options. ")
else:
print("Let's calculate...")
break
【问题讨论】:
-
你的括号不平衡。
-
还有破碎的缩进。
-
我如何找到或更正它?取消缩进并重做?
-
它在
userInputOne行中,但是您也应该能够通过阅读错误消息的回溯来找到它。他们通常指出错误在哪里 -
这是家庭作业吗?为什么你的任务是在 Python 中似乎很少有经验?