recently started learning to use python and I'm trying to make a basic text-based game, and I have run into a slight issue with a function definition where it says there is an indentation error with an elif statement (elif hit_c == 1),(also note I have imported all the needed libraries and defined all variables in the function)
def damage(x):
""" This function will determine the amount of damage you will take """
""" hit_c is the chance the enemy has to hit you """
global User_HP
global Enemy_HP
hit_c = randint(1,5)
User_damage = randint(1,4)
if hit_c >= 2:
Enemy_HP -= User_damage
print(f"You dealt {User_damage} damage!")
print(Enemy_HP)
if Enemy_HP < 0:
elif hit_c == 1:
print("You missed!")
hit_c = randint(1,5)
Enemy_damage = randint(1,3)
if hit_c >= 2:
User_HP -= Enemy_damage
print(f"You took {Enemy_damage} damage!")
print(User_HP)
I don't see any problem with my indentations in my function and not sure why this statement, in particular, is having an error. Help would be much appreciated!
The problem is here:
if Enemy_HP < 0:
elif hit_c == 1:
You forgot to finish the if
statement on the first line.