# Help me please i am super stuck and about to rage

**URL:** <https://discourse.codecombat.com/t/help-me-please-i-am-super-stuck-and-about-to-rage/21067>\
**Category:** Uncategorized\
**Created:** [April 17, 2020, 8:52pm UTC](https://discourse.codecombat.com/t/help-me-please-i-am-super-stuck-and-about-to-rage/21067 "2020-04-17T20:52:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZAX155](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/zax155/32/34141_2.png) [@ZAX155](https://discourse.codecombat.com/u/ZAX155)\
**Post date:** [April 17, 2020, 8:52pm UTC](https://discourse.codecombat.com/t/help-me-please-i-am-super-stuck-and-about-to-rage/21067/1 "2020-04-17T20:52:05Z")

</div>

```python
friends = hero.findFriends()
for friend in friends:
        # Practice using modulo to loop over an array
    # Choose the mix and order of units you want to summon by populating this array:
    summonTypes = ["soldier", "archer"]
    
    def summonTroops():
        # Use % to wrap around the summonTypes array based on len(hero.built)
        #type = summonTypes[???]
        soldier = summonTypes["soldier"]
        archer = summonTypes["archer"]
        len(hero.built) % len(summonTypes)
    
    def collectCoins():
        coin = hero.findNearestItem()
        if coin:
            hero.move(coin.pos)
    
    def commandTroops():
        enemy = hero.findNearestEnemy()
        if enemy:
            hero.summon(soldier, "attack", enemy)
            hero.summon(soldier, "attack", enemy)
        else:
            hero.summon(soldier, "defend", hero.pos)
            hero.summon(archer, "defend", hero.pos)
    while True:
        summonTroops()
        collectCoins()
        commandTroops()

```

here is the error i am getting  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/f/f1d1adbc7848bb564b454f990f1a049b9a72f149.png)

---

<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:** [April 18, 2020, 9:27am UTC](https://discourse.codecombat.com/t/help-me-please-i-am-super-stuck-and-about-to-rage/21067/2 "2020-04-18T09:27:38Z")

</div>

Please stick to one topic, I’ve said this too many times…

> [@\[SOLVED\] Mixed Unit Tactics - Python](https://discourse.codecombat.com/t/solved-mixed-unit-tactics-python/20896/35):
>
> Hi @ZAX155, I think you’re code needs a bit of… restructuring. Let’s look at this on a large scale, because you’re problem is on a large scale (the error message is the least of your worries I’m afraid) The overall structure of your code at the moment is: for friend in friends: summonTypes def summonTroops(): def collectCoins(): def commandTroops(): while True: # call functions Why are you defining the functions and running the while True loop inside a for loop? …

Thanks  
Danny

---

<div class="post-metadata">

**Author:** ![shayaan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/shayaan/32/16846_2.png) [@shayaan](https://discourse.codecombat.com/u/shayaan)\
**Post date:** [April 25, 2020, 1:11pm UTC](https://discourse.codecombat.com/t/help-me-please-i-am-super-stuck-and-about-to-rage/21067/3 "2020-04-25T13:11:33Z")

</div>

Read hints??? Hints help you alot.
