[SOLVED] Brittle Morale

okay, now it says: type error: cannot read property of legnth of undefined.

can you just, show me your code please?

Iā€™m tired.
like really, i was so coding,

make image into strongestHealth = enemy.health

can you show me the , the proper while enemyIndex < len(enemies):???

if itā€™s correct, please tell me !

yours is correct 2000

but it says length is not defined

show me your code please

hereā€™s mine and it worked

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 = enemies[enemyIndex]
    # If enemy.health is greater than strongestHealth
    if enemy.health > strongestHealth:
        
        # Set `strongest` to enemy
        strongest = 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)

Welcome to the forum @[username]! :partying_face: This is a friendly place where you can ask help on levels, report bugs, or just chat with other coders! Donā€™t forget to read the guidelines if you havenā€™t yet. Have a great time!

Please be careful that here you canā€™t post solutions because that would ruin the purpose of playing the game. It would be appreciated if you remove this code if it is working. And always feel free to ask if you need any help :slight_smile: