Brittle Morale (python)

Please help…

# 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
    enemy = hero.findNearestEnemy()
    # While enemyIndex is less than the length of enemies:
    while enemyIndex > len(enemy):
        # Set an enemy variable to enemies[enemyIndex]
        enemy = enemies[enemyIndex]
        # If enemy.health is greater than strongestHealth
        if enemy.health > strongetHealth:
            # Set `strongest` to enemy
            # Set strongestHealth to enemy.health
            strongest = enemy
            strongestHealth = enemy.health
        # Increment enemyIndex
        enemyIndex += 1
    return strongest

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

where is this level?

what do you mean? it is in the desert if that’s what you mean

oh ok (20 characters)

I did it in java can you do java

nevermind but you don’t have to do it in that many lines and that is probably you problem you have so many lines that you just need to simplify it

Could you give me more specific help? It does not need to be less lines, also I would like to learn in python.

This is the first error in you code:

What you’ve written is very contrasting with what the comment above actually says. Read the comment again more carefully.
while enemyIndex is less than the length of enemies

There’s a typo here.
The rest is good.
Danny

This is my new 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
    enemy = hero.findNearestEnemy()
    # While enemyIndex is less than the length of enemies:
    while enemyIndex < len(enemy):
        # 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
            strongest = enemy
            strongestHealth = enemy.health
        # Increment enemyIndex
        enemyIndex += 1
    return strongest

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

This bit isn’t quite right. The comment says:

You do have a variable to do that, you don’t need to make another one.