如果语句不起作用,我希望它们在python中

时间:2015-06-10 11:58:22

标签: python if-statement

嘿,我正在做学习python的艰难之路 我坚持练习36,你要自己建造一些东西。 我有以下代码 我经历了很多时间试图找到我的错误/错误

choice = raw_input("> ")
if choice == "smack it" or "kick it":
    print "the tiger gets angrier and eats your head of"
    exit(0)
elif choice == "offer it the beef" or "offer it beef" or "offer it the beef in my pocket":
    print "the tiger enjoys the treat"
    print "and lets you go to the next room"
    bear_room
else:
    print "the tiger smels the beef you have in you pocket and eats you"
    exit(0)

但问题是,无论我输入什么原始输入,它只是执行就好像第一个if语句是真的并打印"老虎变得愤怒并且吃掉你的头。" 请帮我找到我的错误

1 个答案:

答案 0 :(得分:1)

您应该将choice = raw_input("> ") if choice == "smack it" or choice == "kick it": print "the tiger gets angrier and eats your head of" exit(0) elif choice == "offer it the beef" or choice == "offer it beef" or choice == "offer it the beef in my pocket": print "the tiger enjoys the treat" print "and lets you go to the next room" else: print "the tiger smels the beef you have in you pocket and eats you" exit(0) 添加到所有这些,而不仅仅是第一个。

 <DataGridCell MouseEnter="DataGridCell_MouseEnter"/>