【发布时间】:2013-06-29 02:34:28
【问题描述】:
好的,所以我正在用python编写一个成绩检查代码,我的代码是:
unit3Done = str(input("Have you done your Unit 3 Controlled Assessment? (Type y or n): ")).lower()
if unit3Done == "y":
pass
elif unit3Done == "n":
print "Sorry. You must have done at least one unit to calculate what you need for an A*"
else:
print "Sorry. That's not a valid answer."
当我通过我的 python 编译器运行它并选择 "n" 时,我收到一条错误消息:
"NameError: name 'n' is not defined"
当我选择"y" 时,我得到另一个NameError 'y' 是问题所在,但是当我执行其他操作时,代码运行正常。
非常感谢任何帮助,
谢谢。
【问题讨论】: