Just started learning python through Zed's book "Learn python 3 the hard way". I am currently working on a text based game as an exercise. I got the game running but I could not figure out why the else statement on this specific function does not work. It does work when I take out the OR operator and only equate one choice on the first if statement.
def boss_floor():
boss_hp = 100
your_hp = 100
while boss_hp > 0:
print("Attack boss: 1.sword 2.arrow 3.magic")
attack = input('> ')
if attack == "sword" or "arrow" or "magic":
boss_hp -= random.choice(attack_value)
print("You attack the boss!")
print(f"Boss hp: {boss_hp}\n")
print("Big boss kicks you in the nuts")
your_hp -= random.choice(attack_value)
print(f"hp: {your_hp}\n")
else:
print("Input Invalid")
print(f"Boss hp: {boss_hp}")
if boss_hp <= 0:
print("You win!")
exit(0)
if your_hp <= 0:
print("You lose!")
exit(0)