自制变量在python中不起作用
大家好,说到python,我有点呆头呆脑,我在玩一个未完成的分数转换,我在课堂上就开始了。在“if second==yes:”之前,一切都正常,在未定义的情况下,它会说yes。我该怎么解决这个问题?!?!?!我也是一个noob,我认为这个网站是最容易得到答案的地方(除了学校,但我是cba)。谢谢你的帮助自制变量在python中不起作用,python,Python,大家好,说到python,我有点呆头呆脑,我在玩一个未完成的分数转换,我在课堂上就开始了。在“if second==yes:”之前,一切都正常,在未定义的情况下,它会说yes。我该怎么解决这个问题?!?!?!我也是一个noob,我认为这个网站是最容易得到答案的地方(除了学校,但我是cba)。谢谢你的帮助 print("-------WELCOME-------") testscore = int(input("What mark did you get?")) if testscore>
print("-------WELCOME-------")
testscore = int(input("What mark did you get?"))
if testscore> 75:
print("You got an A!")
else:
if testscore< 30:
print("You got an F")
second = input("do you want to get another test score?")
if second == yes:
if testscore> 75:
print("You got an A!")
else:
if testscore< 30:
print("You got an F")
if second == no:
print("Thanks for using MARK TO GRADE CONVERTER. See you soon!")
print(“----欢迎----”)
testscore=int(输入(“你得到了什么分数?”)
如果testscore>75:
打印(“你得了A!”)
其他:
如果测试分数<30:
打印(“你得了F”)
第二个=输入(“您想获得另一个考试分数吗?”)
如果第二个==是:
如果testscore>75:
打印(“你得了A!”)
其他:
如果测试分数<30:
打印(“你得了F”)
如果第二个==否:
打印(“感谢您使用分数转换。再见!”)
您需要将其置于引号中:
if second == "yes":
实际上,您不是在比较字符串,而是在检查
second
是否等于名为yes
的变量,该变量不存在。如果second==“yes”:
。。。与字符串“yes”比较,不是一个变量yes。if second==“yes”:
非常感谢!