Why isn't elif working? Is it elif or is it the loop that I'm messing up?

I can’t get my code to use the bunkerdown or eject inputs, I tried recreating the problem but I can get anything.
Here’s all the relevant code, if it’s something obvious I apologize I’m new.

fight = 10
wind_up = 15
bunker_down = 0.5
life = 80
dmg_reduction = float(1)
damage_bonus_active = False
damage_bonus = 0
rabbit_health = 30

while rabbit_health > 0:
    enemy_dmg = random.randint (5,12)
    life = life - enemy_dmg * dmg_reduction
    dmg_reduction = 1
    if life <= 0:
        print("You failed, die")
        exit()
    print("You've been hit, lose " + str(enemy_dmg * dmg_reduction) + " Health. " + str(life) + "/80")
    action = input("Fight, Windup, Bunkerdown ")
    if action.upper() == "FIGHT":
        rabbit_health = rabbit_health - fight + damage_bonus
        print("You hit the Rabbit for " + str(fight + damage_bonus) + " HP!")
        damage_bonus = 0
        damage_bonus_active = False
    elif action.upper() == "WINDUP" or "WIND UP":
        if damage_bonus_active is False:
            damage_bonus += wind_up
            print("You Wind up for " + str(wind_up) + " more Damage on your next attack!")
            damage_bonus_active = True
        else:
            print("You just wasted a turn, Moron!")
    elif action.upper() == "BUNKERDOWN" or "BUNKER DOWN":
        dmg_reduction = dmg_reduction - bunker_down
        print("Brace for Impact!")
    elif action == "eject":
        print("ejected")
        exit()
    else:
        print("You just wasted a turn, Moron!")
print("winner!")

I tried to recreate the problem with this block of code but I can’t seem to get it to fail.

testV1 = False
insert = input("insert ")
if insert.upper() == "INSERT":
    print("con1")
elif insert.upper() == "DN":
    print("con2")
elif insert.upper() == "ND":
    if testV1 is False:
        print("bank")
        testV1 = True
    else:
        print("F")
elif insert.upper() == "LL" or "L L":
    print("con4")
else:
    print("false")

>Solution :

action.upper() == "WINDUP" or "WIND UP"

means

( action.upper() == "WINDUP" ) or "WIND UP"

The whole will always result in a true value because "WIND UP" is a true value.

You want

action.upper() == "WINDUP" or action.upper() == "WIND UP" 

Leave a Reply