gpt4 book ai didi

python - 输入(): "NameError: name ' n' is not defined"

转载 作者:太空狗 更新时间:2023-10-29 17:57:22 30 4
gpt4 key购买 nike

<分区>

好的,所以我正在用 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',但是当我做其他事情时,代码正常运行。

非常感谢任何帮助,

谢谢。

30 4 0
文章推荐: angularjs -
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com