我是从一个在线教程学习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