Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Help morale Help plz [SOLVED]

Help

# You have one arrow. Make it count!

# This should return the enemy with the most health.
def findStrongestEnemy(enemies):
    strongest = 0
    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
            # 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)

He is returning strongest but you are not assign it to something try to assign it to a enemy

in where? of the code?

In the start of your code you say
strongest = 0
And you return the strongest
enemyIndex += 1
return strongest
So you need to assign it just above the strongestHealth = enemy.health

What am I suppost to assign?

You have to assign the strongest to the enemy

Thanks I got it.
aaaa

Please put a [SOLVED] thing in the title, so everyone (like me) could see that this is solved.