# \[SOLVED\] Help on Brittle Morale

**URL:** <https://discourse.codecombat.com/t/solved-help-on-brittle-morale/23231>\
**Category:** Level Help\
**Created:** [July 25, 2020, 7:27pm UTC](https://discourse.codecombat.com/t/solved-help-on-brittle-morale/23231 "2020-07-25T19:27:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LunaFromTheMoon](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lunafromthemoon/32/37747_2.png) [@LunaFromTheMoon](https://discourse.codecombat.com/u/LunaFromTheMoon)\
**Post date:** [July 25, 2020, 7:27pm UTC](https://discourse.codecombat.com/t/solved-help-on-brittle-morale/23231/1 "2020-07-25T19:27:51Z")

</div>

```python
# 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):
        enemy = hero.findNearestEnemy()
        # 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
            enemy = strongest
            enemy.health = strongestHealth
        # Increment enemyIndex
        enemyIndex += 1

    return strongest

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

```

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [July 25, 2020, 7:37pm UTC](https://discourse.codecombat.com/t/solved-help-on-brittle-morale/23231/2 "2020-07-25T19:37:54Z")

</div>

You are already passing the array ‘enemies’ to the definition, so you can delete the second line in:

```python
    while enemyIndex < len(enemies):
        enemy = hero.findNearestEnemy()

```

In this next block, you have the variables reversed:

```python
            # Set `strongest` to enemy
            # Set strongestHealth to enemy.health
            enemy = strongest
            enemy.health = strongestHealth

```

For example, “Set ‘strongest’ to enemy” means to make ‘strongest’ equal to ‘eemy’, not the other way around…

---

<div class="post-metadata">

**Author:** ![LunaFromTheMoon](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lunafromthemoon/32/37747_2.png) [@LunaFromTheMoon](https://discourse.codecombat.com/u/LunaFromTheMoon)\
**Post date:** [July 25, 2020, 7:41pm UTC](https://discourse.codecombat.com/t/solved-help-on-brittle-morale/23231/3 "2020-07-25T19:41:59Z")

</div>

Thanks! It worked 😁

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)\
**Post date:** [July 26, 2020, 7:42am UTC](https://discourse.codecombat.com/t/solved-help-on-brittle-morale/23231/4 "2020-07-26T07:42:07Z")

</div>

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