0

So I just started out coding, and my short term goal currently is to make a very small RPG battle simulator (hence the code snippet), and I've been learning Python for a couple days now. I decided to practice with if statements and function and have created this section of code.

health = 7
weak = input("Are you weak? Y/N \n")
action = input("Will you attack? Y/N \n")

def attack(wk, hp):
    if wk == "N" or "n":
        hp -= 3
    else:
        hp -= 2
    return hp


if action == "y" or "Y":
    health = (attack(weak, health))
    print(str(health))
else:
    print("No attack made")

I don't think I've done anything wrong, but no matter what this code always acts like I've made a strong hit to the health and returns 4 before exiting. Does anyone know why this only returns a 4? I've dabbled with other languages (C# and the ModPE namely, which is based off Java) that handled roughly the same structure without fault, so I'm quite confused.

0 Answers0