[SOLVED!] Brittle Morale Level Help!

Hi again, I’m having trouble on the level Brittle Morale, my hero doesn’t seem to do anything…
Here’s my code!

# You have one arrow. Make it count!

# This should return the enemy with the most health.
def findStrongestEnemy(enemies):
    strongest = None
    strongestHealth = 0
    enemyIndex = 0
    # While enemyIndex is less than the length of enemies:
    while enemyIndex < len(enemies):
        
        # Set an enemy variable to enemies[enemyIndex]
        enemy = hero.findNearestEnemy()
        
        # If enemy.health is greater than strongestHealth
        if enemy.health > strongestHealth:
            
            # Set `strongest` to enemy
            # Set strongestHealth to enemy.health
            strongestHealth = enemy.health
        # Increment enemyIndex
        enemyIndex += 1

    return strongest

enemies = hero.findEnemies()
leader = findStrongestEnemy(enemies)
if leader:
    hero.say(leader)

Thanks if you can help! :smile:

This is the problem line. Have another look at what the comment tells you to do.

Jenny

Also you need to do this.

J.

How is there enemies if you haven’t defined them?
For this level, i used for loops, they’re just easier in my opinion.
Lydia

Um… what should the value of the variable be? When I tried

enemies = hero.findNearestEnemies

it came up with the alert "There is no enemy. Try enemy = hero.findNearestEnemy instead.

Oops no nvm I got the answer :slight_smile:
I used the wrong values :sweat_smile:

1 Like

Congrats! :tada:
Lydia

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.