Help: Medical Attention

Indent this

Should be an elif

Lydia

This should be turned into

This

if currentHealth < healingThreshold:
        
        hero.moveXY(65, 46)
        hero.say("heal me")


while True:
    enemy = hero.findNearestEnemy()
    currentHealth = hero.health
    
    
    
    
    elif currentHealth < healingThreshold:
        
        hero.moveXY(65, 46)
        hero.say("heal me")
       
    if enemy:
        hero.attack(enemy)
    

Did it work now(20 char)

no elif or an elif does it need to be an if or an elif

This should be an if

This should be an elif

so you now have this

    elif currentHealth < healingThreshold:
        
        hero.moveXY(65, 46)
        hero.say("heal me")
       
    elif enemy:
        hero.attack(enemy)

it no work and the duck is saying healingThreshold is not defined



while True:
    enemy = hero.findNearestEnemy()
    currentHealth = hero.health
    
    
    
    
    if currentHealth < healingThreshold:
        
        hero.moveXY(65, 46)
        hero.say("heal me")
       
    if enemy:
        hero.attack(enemy)
    

replace this

with this

    enemy = hero.findNearestEnemy()
    currentHealth = hero.health
    healingThreshold = hero.maxHealth / 2

it worked thanks guys

You need to define healingThreshold like this:
healingThreshold = hero.maxHealth / 2

Now mark whichever post helped you solve this problem

i already did that man

You didn’t so just mark this

As solved