解决
输入包含“ 0”或“ 4”的整数时,此if语句仅返回语句中的第一个.
例如,在下面的代码中,如果我输入“ 60”,它将执行:
打印“很好,你不贪心-你赢了!”退出(0)
不
死了(“你这个混蛋!”)
如我所期望的那样,how_much> = 50.
尝试了许多更改,但似乎无法按预期执行.有人知道这是怎么回事吗?
def gold_room():
print "This room is full of gold. How much do you take?"
number_type = False
while True:
choice = raw_input("> ")
how_much = int(choice)
if "0" in choice or "4" in choice and how_much < 50:
print "Nice, you're not greedy - you win!"
exit(0)
elif "0" in choice or "4" in choice and how_much >= 50:
dead("You greedy bastard!")
else:
print "Man, learn to type a number. Put a 0 or a 4 in your number."