【发布时间】:2012-08-10 23:49:13
【问题描述】:
我有一个程序可以问我行星离太阳有多远。唯一的问题是,无论我给出什么答案,它总是显示为正确的。这是我的代码的链接:http://pastebin.com/MimECyjm
如果可能的话,我想要一个更简单的答案,因为我对 python 还不是很精通
有问题的代码:
mercury = "57.9"
mercury2 = "57900000"
def Mercury():
ans = raw_input("How far is Mercury from the sun? ")
if mercury or mercury2 in ans:
print "Correct!"
time.sleep(.5)
os.system("cls")
main()
else:
print "Incorrect!"
Mercury()
【问题讨论】:
-
有 150 行代码,你能缩小问题范围,把相关的代码贴在这里吗? (这个过程也会加深你对代码的理解)
标签: python windows string if-statement boolean