# Pls help in the bane of soldiers

**URL:** <https://discourse.codecombat.com/t/pls-help-in-the-bane-of-soldiers/26734>\
**Category:** Level Help\
**Created:** [January 16, 2021, 9:47pm UTC](https://discourse.codecombat.com/t/pls-help-in-the-bane-of-soldiers/26734 "2021-01-16T21:47:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Wong](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ryan_wong/32/25710_2.png) [@Ryan\_Wong](https://discourse.codecombat.com/u/Ryan_Wong)\
**Post date:** [January 16, 2021, 9:47pm UTC](https://discourse.codecombat.com/t/pls-help-in-the-bane-of-soldiers/26734/1 "2021-01-16T21:47:54Z")

</div>

Here is my code:

```python
while True:
    enemies = hero.findEnemies()
    enemy = hero.findNearest(enemies)
    friends = hero.findFriends()
    
    # Send the first soldier of the friends array towards the enemy.
    for i in range(0, len(friends)):
        friend = friends[1]
        hero,command(friend, "move", {"x":16,"y":16})
        pass
    # i in range(1, n) starts the index at the second element!
    for i in range(1, len(friends)):
        friend = friends[i]
        # Command the remaining soldiers to run away!
        hero.command(friend, "move", {"x":30, "y":36})

```

only one of the soldiers go to the bomb and it only explodes one bomb

---

<div class="post-metadata">

**Author:** ![Ryan\_Wong](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ryan_wong/32/25710_2.png) [@Ryan\_Wong](https://discourse.codecombat.com/u/Ryan_Wong)\
**Post date:** [January 16, 2021, 9:50pm UTC](https://discourse.codecombat.com/t/pls-help-in-the-bane-of-soldiers/26734/3 "2021-01-16T21:50:15Z")

</div>

What is Html? (20 chars)

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [January 16, 2021, 9:56pm UTC](https://discourse.codecombat.com/t/pls-help-in-the-bane-of-soldiers/26734/4 "2021-01-16T21:56:12Z")

</div>

> [@Ryan\_Wong](#):
>
> ```python
> for i in range(0, len(friends)):
> friend = friends[1]
> hero,command(friend, "move", {"x":16,"y":16})
> pass
> 
> ```

for this you can just do

```python
for friend in friends:
        hero.command(friend, "move", enemy.pos)

```

---

<div class="post-metadata">

**Author:** ![jka2706](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/jka2706/32/13636_2.png) [@jka2706](https://discourse.codecombat.com/u/jka2706)\
**Post date:** [January 17, 2021, 10:29am UTC](https://discourse.codecombat.com/t/pls-help-in-the-bane-of-soldiers/26734/6 "2021-01-17T10:29:01Z")

</div>

@milton.jinich that isn’t very kind, and doesn’t help someone learn.

@Ryan_Wong, you have:

```python
hero,command

```

which is making that line of code not work. However, have another look at the two lines above it. You’re only trying to command one soldier, so you don’t need the for loop to go through all of them.

Jenny

---

<div class="post-metadata">

**Author:** ![WaWa\_Yang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wawa_yang/32/17800_2.png) [@WaWa\_Yang](https://discourse.codecombat.com/u/WaWa_Yang)\
**Post date:** [January 17, 2021, 8:58pm UTC](https://discourse.codecombat.com/t/pls-help-in-the-bane-of-soldiers/26734/7 "2021-01-17T20:58:15Z")

</div>

> [@Eric\_Tang](#):
>
> ```python
> for friend in friends:
> hero.command(friend, "move", enemy.pos)
> 
> ```

well not really cause each and every single one of them are going to move. In my code at least i have a loop that checks the enemy.

> **Hint**
>
> ```python
> if enemy:
> friend = friends[0]
> 
> ```
> 
> and t hen a command that moves them to the enemy. I recommend you getting away from the enemy more like
> 
> ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/8/9/897f24ed208703966183aff6ab662da08299344d.jpeg)  
> here.
> 
> > [@Ryan\_Wong](#):
> >
> > `{"x":16,"y":16})`
> 
> replace that with enemy.pos

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [January 17, 2021, 8:59pm UTC](https://discourse.codecombat.com/t/pls-help-in-the-bane-of-soldiers/26734/8 "2021-01-17T20:59:39Z")

</div>

Well I did it my way and it worked.

---

<div class="post-metadata">

**Author:** ![WaWa\_Yang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wawa_yang/32/17800_2.png) [@WaWa\_Yang](https://discourse.codecombat.com/u/WaWa_Yang)\
**Post date:** [January 17, 2021, 10:34pm UTC](https://discourse.codecombat.com/t/pls-help-in-the-bane-of-soldiers/26734/9 "2021-01-17T22:34:06Z")

</div>

duno…Before i tried but it send about 3 at a time
