import random
hp = 100
eh = 100
while hp > 0 and eh > 0:
print("Action? (attack, heal, nothing):")
act = input(">")
attack = random.randint(1, 30)
heal = random.randint(1, 15)
if act == "attack" or "Attack":
eh = eh - attack
print(attack)
print("eh = %s" % eh)
elif act == "heal" or "Heal":
hp = hp + heal
print("You have healed %s points" % heal)
print(hp)
爲什麼當我輸入heal時,它也會運行攻擊部分呢?即使我輸入既沒有攻擊也沒有治療,它仍然會運行攻擊部分。請幫我用我的代碼(Python)
遇見一個有用的[方法](http://docs.python.org/2/library/stdtypes.html#str.lower):'如果行爲。lower()==「attack」:' – dawg