# Hunting Party (Python) Bug or User Error?

**URL:** <https://discourse.codecombat.com/t/hunting-party-python-bug-or-user-error/11883>\
**Category:** Bugs\
**Created:** [July 5, 2017, 3:59pm UTC](https://discourse.codecombat.com/t/hunting-party-python-bug-or-user-error/11883 "2017-07-05T15:59:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skillster](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/skillster/32/6509_2.png) [@Skillster](https://discourse.codecombat.com/u/Skillster)\
**Post date:** [July 5, 2017, 3:59pm UTC](https://discourse.codecombat.com/t/hunting-party-python-bug-or-user-error/11883/1 "2017-07-05T15:59:24Z")

</div>

Hey there, trying to complete the level Hunting Party, and everything I’ve been trying is giving me errors. Any help would be appreciated! Here is my code:

```python
# Command your troops to move east and attack any ogres they see.
# Use for-loops and findFriends.
# You can use findNearestEnemy() on your soldiers to get their nearest enemy instead of yours.

friend = hero.findFriends()
for a in friend:
    enemy = friend[a].findNearestEnemy()
    movement = ({'x':friend[a].pos.x+2,'y':friend[a].pos.y})
    hero.command(friend[a], "move", movement)
    if enemy:
        hero.command(friend[a], "attack", enemy)
    a +=1

```

> **[Gyazo](https://gyazo.com/5b485d4500571ab3a373e8fa3a6d81b4)**
>
> ​

---

<div class="post-metadata">

**Author:** ![Hellenar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellenar/32/9100_2.png) [@Hellenar](https://discourse.codecombat.com/u/Hellenar)\
**Post date:** [July 5, 2017, 5:37pm UTC](https://discourse.codecombat.com/t/hunting-party-python-bug-or-user-error/11883/2 "2017-07-05T17:37:54Z")

</div>

```python
movement = ({'x':friend[a].pos.x+2,'y':friend[a].pos.y})

```

I don’t think you need the regular parentheses in that line.

---

<div class="post-metadata">

**Author:** ![Skillster](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/skillster/32/6509_2.png) [@Skillster](https://discourse.codecombat.com/u/Skillster)\
**Post date:** [July 5, 2017, 5:44pm UTC](https://discourse.codecombat.com/t/hunting-party-python-bug-or-user-error/11883/3 "2017-07-05T17:44:42Z")

</div>

Actually that line seems to be fine. I made some progress by changing the for loop from:

```python
for a in friend:

```

to

```python
for a in range(len(friend)):

```

Now my minions will run to their designated locations but won’t stop to kill any enemies. Progress is being made!

---

<div class="post-metadata">

**Author:** ![Skillster](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/skillster/32/6509_2.png) [@Skillster](https://discourse.codecombat.com/u/Skillster)\
**Post date:** [July 5, 2017, 6:41pm UTC](https://discourse.codecombat.com/t/hunting-party-python-bug-or-user-error/11883/4 "2017-07-05T18:41:20Z")

</div>

Okay, I was an idiot (surprise!). Code loop worked just fine with the “for a in range(len(friend)):” change. I simply forgot to include the game loop (while True:). 🙄
