# Friend and Foe Level Help \[solved\]

**URL:** <https://discourse.codecombat.com/t/friend-and-foe-level-help-solved/19079>\
**Category:** Solved\
**Created:** [August 23, 2019, 4:38pm UTC](https://discourse.codecombat.com/t/friend-and-foe-level-help-solved/19079 "2019-08-23T16:38:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fogledude102](https://avatars.discourse-cdn.com/v4/letter/f/41988e/32.png) [@fogledude102](https://discourse.codecombat.com/u/fogledude102)\
**Post date:** [August 23, 2019, 4:38pm UTC](https://discourse.codecombat.com/t/friend-and-foe-level-help-solved/19079/1 "2019-08-23T16:38:06Z")

</div>

In the level Friend and Foe in the Backwoods Forest, I am having trouble figuring out the correct way to complete the level. Here is my code:

```python
# Peasants and peons are gathering in the forest.
# Command the peasants to battle and the peons to go away!

while True:
    friend = hero.findNearestFriend()
    enemy = hero.findNearestEnemy()
    if friend:
        hero.say("To battle, " + friend.id + "!")
    # Now find the nearest enemy and tell them to go away.
    if enemy:
        hero.say("Go away, " + enemy.id + "!")
    

```

Any suggestions?

---

<div class="post-metadata">

**Author:** ![fogledude102](https://avatars.discourse-cdn.com/v4/letter/f/41988e/32.png) [@fogledude102](https://discourse.codecombat.com/u/fogledude102)\
**Post date:** [August 23, 2019, 4:43pm UTC](https://discourse.codecombat.com/t/friend-and-foe-level-help-solved/19079/2 "2019-08-23T16:43:31Z")

</div>

It works now ¯\_(ツ)\_/¯  
I just exited out and went back in again, and it just started working. Sorry if wasted your time by making you read this

---

<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:** [August 31, 2019, 7:50am UTC](https://discourse.codecombat.com/t/friend-and-foe-level-help-solved/19079/3 "2019-08-31T07:50:19Z")

</div>

> [@fogledude102](#):
>
> Sorry if wasted your time by making you read this

No worries, we’re always happy to help.  
-Danny
