# Need help with: Forest, Backwoods Brawl4

**URL:** <https://discourse.codecombat.com/t/need-help-with-forest-backwoods-brawl4/20052>\
**Category:** Level Help\
**Created:** [January 19, 2020, 4:35pm UTC](https://discourse.codecombat.com/t/need-help-with-forest-backwoods-brawl4/20052 "2020-01-19T16:35:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [January 19, 2020, 4:35pm UTC](https://discourse.codecombat.com/t/need-help-with-forest-backwoods-brawl4/20052/1 "2020-01-19T16:35:52Z")

</div>

I made it to round 4, but now am stuck. I’ve tried to resolve this several ways, but no luck:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/9/918e5041b03224c9fa518e731183f2205366e305.png)

The code never progresses past the friends = line, so no idea if one of my attempts (shown) even helps. Code:

```python
def commandTroops():
    friends = hero.findFriends()
    if friends == None:
        pass
    else:
        for x in len(friends):
            friend = friends[x]
            if friend.type == "paladin":
                CommandPaladin(friend)
            elif friend.type == "soldier" or friend.type == "archer" or friend.type == "griffin-rider":
                CommandSoldier(friend)
            elif friend.type == "peasant":
                CommandPeasant(friend)

```

I’m betting it’s something simple, but darned if I see it. Oh…at this point, I no longer have any friends left alive and not yet enough gold to summon more.

---

<div class="post-metadata">

**Author:** ![xython](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/xython/32/7269_2.png) [@xython](https://discourse.codecombat.com/u/xython)\
**Post date:** [January 19, 2020, 10:20pm UTC](https://discourse.codecombat.com/t/need-help-with-forest-backwoods-brawl4/20052/2 "2020-01-19T22:20:41Z")

</div>

What will be the value of friends if there are no friends?

```python
friends = hero.findFriends()

```

see [hero.findEnemies() Quiz](https://discourse.codecombat.com/t/hero-findenemies-quiz/17873)

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [January 19, 2020, 10:57pm UTC](https://discourse.codecombat.com/t/need-help-with-forest-backwoods-brawl4/20052/3 "2020-01-19T22:57:47Z")

</div>

Heh, that’s my problem…no friends 😉

I tried the link you provided and replaced with the specified code, but it returns ‘so many enemies’…It’s seeing the wiz as an enemy?

---

<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:** [January 20, 2020, 5:52pm UTC](https://discourse.codecombat.com/t/need-help-with-forest-backwoods-brawl4/20052/4 "2020-01-20T17:52:57Z")

</div>

I did a bit of testing and the only thing I could do to stop the error message: “TypeError: Need an object” was to change this line:

```python
for x in len(friends):

```

This is incorrect (I’m pretty sure).  
You can do:

```python
for unit in units:
    #code

```

or (I think more commonly used in python):

```python
for i in range(0, len(units)):
    unit = units[i]
    #code

```

This may have been what @Xython was saying but I’m not sure.  
I hope this helps anyway.

---

<div class="post-metadata">

**Author:** ![xython](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/xython/32/7269_2.png) [@xython](https://discourse.codecombat.com/u/xython)\
**Post date:** [January 20, 2020, 9:39pm UTC](https://discourse.codecombat.com/t/need-help-with-forest-backwoods-brawl4/20052/5 "2020-01-20T21:39:32Z")

</div>

Deadpool is right about this error. But I think your main error is elsewhere:  
Type this code in completely void level ([https://codecombat.com/play/level/forest-flower-grove?)](https://codecombat.com/play/level/forest-flower-grove?))  
( I suppose you have the most advanced glaces)

```python
items = hero.findItems();
friends = hero.findFriends()
enemies = hero.findEnemies()
ogres = hero.findByType("ogre")
friendlyMissiles = hero.findFriendlyMissiles()
enemyMissiles = hero.findEnemyMissiles()
hazards = hero.findHazards()
if items and friends and enemies and ogres and friendlyMissiles and enemyMissiles and hazards:
    hero.say("Maybe they are all of Dark Material")
else:
    hero.say("Nothing here")

```

If the result

 ![dark](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/f/fc61d92f47d5e3677dcc5a3c0fd23854149a5e18.jpeg)  
is unexpected for you read carefully the whole hero-findenemies-quiz topic

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [January 20, 2020, 9:42pm UTC](https://discourse.codecombat.com/t/need-help-with-forest-backwoods-brawl4/20052/6 "2020-01-20T21:42:57Z")

</div>

Ok, thanks @Deadpool198 and @xython! Yes, I have the best glasses…I will try these suggestions out and see where it leads me. 🙂

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [January 20, 2020, 10:35pm UTC](https://discourse.codecombat.com/t/need-help-with-forest-backwoods-brawl4/20052/7 "2020-01-20T22:35:46Z")

</div>

Ok…got past that error!

@Deadpool198 thanks…changing to the common python method was the trick.

@xython Thanks again…after trying it with both the enchanted lenses and twilight glasses, I saw dark matter both times, I think I realized your point. I modified the code to utilize the ‘for i in range’ method, for each unit type and I never saw a thing. Lesson well learned 😃
