如果action ==“a”或“A”总是运行

时间:2014-08-11 00:50:45

标签: python if-statement

问:lpthw问题。我跑的时候:

action = raw_input("Choose a letter> ")

if action == "a" or "A":
    dead("Well this feels good, \nI think I'll just sit here forever like this.")
elif action == "b" or "B":
    god_appearance("God says: Cool, you need some help?")
elif action == "c" or "C":
    success()
else:
    not_an_option()

无论raw_input,函数dead()都会返回。但是,当我在没有"或"的情况下运行相同的代码时语句,if语句返回预期的函数。例如:

if action == "a":
    dead("Well this feels good, \nI think I'll just sit here forever like this.")
elif action == "b":
    god_appearance("God says: Cool, you need some help?")
elif action == "c":
    success("You win the three wolves and a moon t-shirt!")
else:
    not_an_option()

为什么?提前谢谢!

0 个答案:

没有答案