# Steelclaw Gap help

**URL:** <https://discourse.codecombat.com/t/steelclaw-gap-help/16135>\
**Category:** Uncategorized\
**Created:** [October 8, 2018, 12:43pm UTC](https://discourse.codecombat.com/t/steelclaw-gap-help/16135 "2018-10-08T12:43:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mratranslate](https://avatars.discourse-cdn.com/v4/letter/m/e99b99/32.png) [@mratranslate](https://discourse.codecombat.com/u/mratranslate)\
**Post date:** [October 8, 2018, 12:43pm UTC](https://discourse.codecombat.com/t/steelclaw-gap-help/16135/1 "2018-10-08T12:43:31Z")

</div>

```python
# This level introduces the % operator, also known as the modulo operator.
# a % b returns the remainder of a divided by b
# This can be used to wrap around to the beginning of an array when an index might be greater than the length

defendPoints = [{"x": 35, "y": 63},{"x": 61, "y": 63},{"x": 32, "y": 26},{"x": 64, "y": 26}]

summonTypes = ["soldier","soldier","soldier","soldier","archer","archer","archer","archer"]

# You start with 360 gold to build a mixture of soldiers and archers.
# self.built is an array of the troops you have built, ever.
# Here we use "len(self.built) % len(summonTypes)" to wrap around the summonTypes array
def summonTroops():
    type = summonTypes[len(hero.built) % len(summonTypes)]
    if hero.gold >= hero.costOf(type):
        hero.summon(type)

def commandTroops():
    friends = hero.findFriends()
    for i in range(len(friends)):
        friend = friends[i]
        friendIndex = 0
        defPon = defendPoints[friendIndex % 4]
        friendIndex += 1
        hero.command(friend, "defend", defPon)
    
        # Use % to wrap around defendPoints based on friendIndex
        
        # Command your minion to defend the defendPoint
        

while True:
    summonTroops()
    commandTroops()

```

Please can I get some help! All my friends are just going straight to the left hand top corner, i.e. defend point 1. I presume this is because my friend index is not incrementing? But unsure why?

Thanks

---

<div class="post-metadata">

**Author:** ![CodeVoodoo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/codevoodoo/32/9184_2.png) [@CodeVoodoo](https://discourse.codecombat.com/u/CodeVoodoo)\
**Post date:** [October 8, 2018, 4:05pm UTC](https://discourse.codecombat.com/t/steelclaw-gap-help/16135/2 "2018-10-08T16:05:32Z")

</div>

> [@mratranslate](#):
>
> for i in range(len(friends)): friend = friends[i] friendIndex = 0

be consistent in using i or friendIndex  
try change friend = friends[i] to friend = friends[friendIndex] and change for frendIndex in range(len(friends():
