import random
import sys
Hdie = "A human has fallen."
Zdie = "A zombie has fallen!"
No = "Nothing happened."
Randeve = (Hdie, Zdie, No)
NumH = int(raw_input("How many humans are on your team?"))
NumZ = int(raw_input("How many zombies are in the area?"))
if NumH >= 101:
print "Maximum humans is 100."
sys.exit()
if NumZ >= 121:
print "Maximum zombies is 120."
sys.exit()
print(random.choice(Randeve))
if Randeve == Hdie:
print "hi"
每当我运行它并打印Hdie
时,它就不会打印hi
。救救我!
答案 0 :(得分:4)
将random.choice(Randeve)
的结果分配给变量,并在适用的两个地方使用它。
x = random.choice(Randeve)
print(x)
if x == Hdie:
print "hi"