Sarven outpost python hero ignores enemies because of glasses?

problem:
hero ignores enemy
do I need special glasses to detect enemy health?

Here is the code that does not work:

(need to add four spaces and two blank lines to get the code to format properly!)

    # Check for ogres and defeat them!
    enemy = hero.findNearestEnemy()
    if enemy:
        if enemy.health <= 0:
            hero.attack(enemy)
    # Make sure to attack the ogres while their health is above 0.

If I comment out it works… again, is this a ‘glasses’ issue?

if enemy.health <= 0:

    if enemy:
        #if enemy.health <= 0:
        hero.attack(enemy)
    # Make sure to attack the ogres while their health is above 0.

it means: Attack the enemy if it’s dead :wink:

1 Like

Doh!

Thanks for the tip. Many eyes make for shallow bugs or in this case many eyes makes it clear that I am not thinking clearly! :slight_smile: