我是從一個在線教程學習Python的。我的問題是,當我運行該腳本,不管是什麼我輸入的響應我得到的是,如果去==「廚房」 ......Python函數運行到第一個if語句不管輸入
def go_to():
go = raw_input("Go to? ")
if go == Kitchen or breakfast:
print "You rumble down stairs and into the kitchen. Your mom has left some microwaved waffles on the table for you. Your big boy step sits by the counter."
elif go == "back to bed" or "back to sleep" or bed or sleep:
print "You hit snooze and roll over."
elif go == "bathroom" or "toilet" or "potty" or "pee" or "poop" or "take a sh*t" or "take a dump" or "drop a load":
print "You make a stop at the head first."
go_to()
else:
print "That is not a command I understand."
go_to()
go_to()
您需要一個新的教程,因爲'or'的用法不正確。 – 2012-08-02 15:34:26
就目前而言,這個程序會因爲語法錯誤而中止。縮進在Python中很重要。請解決這個問題。此外,你有'牀'和'睡眠'這些沒有引用的東西。當你的函數被調用時,這也會出錯。 – 2012-08-02 15:36:36
你不喜歡''''和'''字符,是嗎? – glglgl 2012-08-02 15:41:03