# \[SOLVED\] Steelclaw Gap \[Python\]

**URL:** <https://discourse.codecombat.com/t/solved-steelclaw-gap-python/22208>\
**Category:** Level Help\
**Created:** [June 14, 2020, 4:01am UTC](https://discourse.codecombat.com/t/solved-steelclaw-gap-python/22208 "2020-06-14T04:01:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon66968315](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anon66968315](https://discourse.codecombat.com/u/anon66968315)\
**Post date:** [June 14, 2020, 4:01am UTC](https://discourse.codecombat.com/t/solved-steelclaw-gap-python/22208/1 "2020-06-14T04:01:55Z")

</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]
        # Use % to wrap around defendPoints based on friendIndex
        friendIndex = 0
        defPoi = defendPoints[friendIndex % len (defendPoints)]
        # Command your minion to defend the defendPoint
        hero.command(friend, "defend", defPoi)
        friendIndex += 1

while True:
    summonTroops()
    commandTroops()

```

idk what i’m getting wrong, pls help. Tks!

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 14, 2020, 4:18am UTC](https://discourse.codecombat.com/t/solved-steelclaw-gap-python/22208/2 "2020-06-14T04:18:22Z")

</div>

> [@anon66968315](#):
>
> `friendIndex = 0`

Delete this

> [@anon66968315](#):
>
> `friendIndex += 1`

Delete this, too.

> [@anon66968315](#):
>
> `friendIndex % len`

Instead of **friendIndex** put the variabile **i**.  
Does it work now?

---

<div class="post-metadata">

**Author:** ![anon66968315](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anon66968315](https://discourse.codecombat.com/u/anon66968315)\
**Post date:** [June 14, 2020, 4:30am UTC](https://discourse.codecombat.com/t/solved-steelclaw-gap-python/22208/3 "2020-06-14T04:30:25Z")

</div>

yes tks. btw how do you get the bonus?

---

<div class="post-metadata">

**Author:** ![anon66968315](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anon66968315](https://discourse.codecombat.com/u/anon66968315)\
**Post date:** [June 14, 2020, 4:32am UTC](https://discourse.codecombat.com/t/solved-steelclaw-gap-python/22208/4 "2020-06-14T04:32:50Z")

</div>

nvm i got the bonus (20 chars)

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 14, 2020, 4:33am UTC](https://discourse.codecombat.com/t/solved-steelclaw-gap-python/22208/5 "2020-06-14T04:33:04Z")

</div>

Try resummiting a couple of times and you will get it.

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 14, 2020, 4:34am UTC](https://discourse.codecombat.com/t/solved-steelclaw-gap-python/22208/6 "2020-06-14T04:34:31Z")

</div>

Then, congratulations! 🥳

---

<div class="post-metadata">

**Author:** ![anon66968315](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@anon66968315](https://discourse.codecombat.com/u/anon66968315)\
**Post date:** [June 14, 2020, 4:35am UTC](https://discourse.codecombat.com/t/solved-steelclaw-gap-python/22208/7 "2020-06-14T04:35:52Z")

</div>

tks! (20 characters)
