Ask coding questions

← Back to all posts
Certain problem
NathanWeems (5)

So when I type fireball, it's draining HP until it is at 0 instead of just once and I'm not sure how to fix it

LukeWright (286)

why don't you make it so that everytime you take a chunk of health, it sets the choice variable to an empty string so that it only triggers once?
you would do it like this:

elif choice == "water blast":
  enemy_hp -= 2
  choice = ""

also, to save time instead of writing

enemy_hp = enemy_hp - 1

, you could just write

enemy_hp -= 1
LukeWright (286)

Click the checkmark next to my comment if I gave you the correct answer! @NathanWeems

NathanWeems (5)

@LukeWright It didn't fix it. When I type "water blast" one time, it says invalid input forever

LukeWright (286)

there must be something wrong with your input statement. Try putting something in it like

choice = input("What would you like your attact to be: ")

or try retyping the input statement and specifying which variable type you would like to use

choice = str(input("Choose something: "))


NathanWeems (5)

@LukeWright Still doing the infinite "invalid inputs" and then when I do fireball it drains everything instantaneously

IGamer123 (76)

Firstly I don't know python with turtle so sorry bout that
second, this happens -

NathanWeems (5)

@IGamer123 The turtle is just for animations, the actual Python should be the exact same