You need to change the enemy health outside of the print statement with a statement like this:
enemy1_health = enemy1_health - 20
or like this, which does the same thing:
enemy1_health -= 20
You also reset enemy1_health every time the loop loops, remove that.
You don't define player_health, define that.
Your loop goes forever until you die.
So your code should end up looking more like this:
enemy1_health = 150
broadsword_attack = 20
rusty_knife = 10.5
player_health = 100
attacks = ["broadsword swing " + str(broadsword_attack), "rusty knife jab " + str(rusty_knife)]
while enemy1_health > 0:
print(attacks)
attackchoice = input("Choose an attack: ")
if attackchoice == ("broadsword swing"):
enemy1_health -= 20
if attackchoice == ("rusty knife jab"):
enemy1_health -= 10.5
print(enemy1_health)
if player_health <= 0:
print("you died")
quit()
print("you cleared the level")
This still requires quite a bit of tweaking, it'd be a complete working game if it was like this (basically, you win if you spam broadsword attacks because they do more damage):
enemy1_health = 150
enemy1_attack = 10
player_health = 100
broadsword_attack = 20
rusty_knife = 10.5
attacks = ["broadsword swing " + str(broadsword_attack), "rusty knife jab " + str(rusty_knife)]
while enemy1_health > 0:
print(attacks)
attackchoice = input("Choose an attack: ")
if attackchoice == ("broadsword swing"):
enemy1_health -= broadsword_attack
if attackchoice == ("rusty knife jab"):
enemy1_health -= rusty_knife
print(f'A hit! The enemy has {enemy1_health} health left.')
if enemy1_health > 0:
player_health -= enemy1_attack
print(f'The enemy attacks and leaves you with {player_health} health.')
if player_health <= 0:
print("you died")
quit()
print("you cleared the level")