我還沒有開始使用python,我查看了很多帖子在這裏,但似乎無法解決什麼是我的代碼錯了... 如果用戶輸入N或n,那麼我的elif肯定會踢,但它仍然播放聲音並打印出「播放聲音」。 任何人都可以幫忙嗎?謝謝。Python - 如果,elif語句
test2 = raw_input("Would you like to test the sound? Y\N or exit? ")
if test2 == "Y" or "y":
winsound.PlaySound('C:/Windows/Media/tada.wav', winsound.SND_FILENAME)
print ("Sound Played")
elif test2 == "N" or "n":
print ("Test skipped")
elif test2 == "exit":
print ("Test exit")
else:
print ("Please choose an option")
的可能的複製[如何測試對多值一個變量?](http://stackoverflow.com/questions/15112125/how-do-i-test-one-variable-against-multiple-values) –
哇,它就像一個終極重複,但4個答案(並沒有_actual_解釋**爲什麼**發生這種情況)必須發佈。尼斯... –