# Grim determination - please help

**URL:** <https://discourse.codecombat.com/t/grim-determination-please-help/26835>\
**Category:** Level Help\
**Created:** [January 20, 2021, 4:09pm UTC](https://discourse.codecombat.com/t/grim-determination-please-help/26835 "2021-01-20T16:09:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![QinWentian](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/qinwentian/32/17063_2.png) [@QinWentian](https://discourse.codecombat.com/u/QinWentian)\
**Post date:** [January 20, 2021, 4:09pm UTC](https://discourse.codecombat.com/t/grim-determination-please-help/26835/1 "2021-01-20T16:09:01Z")

</div>

```python
# Your goal is to protect Reynaldo

# Find the paladin with the lowest health.
def lowestHealthPaladin():
    lowestHealth = 99999
    lowestFriend = None
    friends = hero.findFriends()
    for friend in friends:
        if friend.type != "paladin":
            continue
        if friend.health < lowestHealth and friend.health < friend.maxHealth:
            lowestHealth = friend.health
            lowestFriend = friend

    return lowestFriend

def commandPaladin(paladin):
    # Heal the paladin with the lowest health using lowestHealthPaladin()
    # You can use paladin.canCast("heal") and command(paladin, "cast", "heal", target)
    # Paladins can also shield: command(paladin, "shield")
    # And don't forget, they can attack, too!
    lowestHealthPaladin()
    if paladin.canCast("heal"):
        if lowestFriend:
            hero.command(paladin, "cast", "heal", lowestFriend)
    hero.command(paladin, "shield")
    pass

def commandFriends():
    # Command your friends.
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "peasant":
            #commandPeasant(friend)
            pass
        elif friend.type == "griffin-rider":
            #commandGriffin(friend)
            pass
        elif friend.type == "paladin":
            commandPaladin(friend)

while True:
    commandFriends()
    if hero.gold>hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")
    for friend in hero.findFriends():
        if friend.type == "griffin-rider":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
            else:
                hero.command(friend, "move", {"x": 62, "y": 37})    

```

I get that my code is not complete but I don’t understand what the issue is.

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [January 20, 2021, 4:33pm UTC](https://discourse.codecombat.com/t/grim-determination-please-help/26835/2 "2021-01-20T16:33:40Z")

</div>

> [@QinWentian](#):
>
> ```python
> lowestHealthPaladin()
> if paladin.canCast("heal"):
> if lowestFriend:
> hero.command(paladin, "cast", "heal", lowestFriend)
> hero.command(paladin, "shield")
> 
> ```

You have to make a variable called lowestFriend and store the value of the function lowestHealthPaladin() inside it. If the function has a return inside it, it means you need to put it to the right of an equals sign like with hero.findNearestEnemy().

---

<div class="post-metadata">

**Author:** ![QinWentian](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/qinwentian/32/17063_2.png) [@QinWentian](https://discourse.codecombat.com/u/QinWentian)\
**Post date:** [January 20, 2021, 4:41pm UTC](https://discourse.codecombat.com/t/grim-determination-please-help/26835/3 "2021-01-20T16:41:52Z")

</div>

Ahhh, thank you (20)
