Help on medical attention

I need help figuring out the problem that I am having. Can anyone help?
This is my code.

while True:
    currentHealth = hero.health
    healingThreshold = hero.maxHealth / 2
    # If your current health is less than the threshold,
    # move to the healing point and say, "heal me".
    # Otherwise, attack. You'll need to fight hard!
    if enemy:
	    enemy = self.findNearestEnemy()
    if  currentHealth < healingThreshold :
        hero.moveXY(65, 46)
        hero.say("Healing please")
    elif enemy:
        hero.shield()  
        hero.attack(enemy)
        hero.attack(enemy)
        hero.attack(enemy)

Thank you for the properly formatted code:

The first problem I see:

if enemy:
    enemy = self.findNearestEnemy()

You haven’t declared the variable enemy yet, and are only assigning it if the non-existent variable is true.

Okay, Thank you for the comment I read the FAQ because I have been reading other peoples work for a while and I have noticed that every new person hasn’t formatted their code right.

How did I not declare the variable “enemy”?