我真的很陌生,我剛做了一個小程序。如果你輸入「你好」或「你好」,它會說「工作」,如果你輸入其他的東西,它會說「不工作」。下面的代碼我到目前爲止:Python 2 - 如何使用'或'?
print "Type in 'Hello'"
typed = raw_input("> ")
if (typed) == "Hello" or "hello":
print "Working"
else:
print "not working"
的代碼無法正常工作,無論我提交總是會說「工作」,即使我鍵入「jsdfhsdkfsdhjk」。如果我拿出「或」和「你好」,它確實有效,但我想檢查兩者。我怎樣才能使腳本工作?
非常感謝!
+1對'in'。最好的使用。 – quantum