# Summit's gate pls help me (python)

**URL:** <https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420>\
**Category:** Level Help\
**Created:** [January 7, 2021, 5:16pm UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420 "2021-01-07T17:16:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefan\_grecu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/stefan_grecu/32/20456_2.png) [@stefan\_grecu](https://discourse.codecombat.com/u/stefan_grecu)\
**Post date:** [January 7, 2021, 5:16pm UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/1 "2021-01-07T17:16:06Z")

</div>

i need help with this level  
this is the code:

```python
while True:
    paladins = []
    enemies = hero.findNearestEnemy()
    greenFlag = hero.findFlag("green")
    blackFlag = hero.findFlag("black")
    violetFlag = hero.findFlag("violet")
    if violetFlag:
        friends = hero.findFriends()
        if friends:
            for friend in friends:
                if friend:
                    hero.command(friend, "move", violetFlag.pos)
    if greenFlag:
        hero.pickUpFlag(greenFlag)
    if blackFlag:
        hero.pickUpFlag(blackFlag)
        hero.attack(enemy)
    if hero.canCast("invisibility", hero):
        hero.cast("invisibility", hero)
    friends = hero.findFriends()
    for enemy in hero.findEnemies():
        friends = hero.findFriends()
        for friend in friends:
            e = friend.findNearestEnemy()
            if e:
                hero.command(friend, "attack", e)
    fire = hero.findNearestEnemy()
    if fire:
        while fire.health > 0:
            if hero.canCast("invisibility", hero):
                hero.cast("invisibility", hero)
            hero.attack(fire)
            hero.shield()
        if fire.type == "tower":
            pass
        if hero.gold > hero.costOf("soldier"):
            hero.summon("soldier")
    if hero.health < 3000:
        for friend in friends:
            if friend and friend.type == "paladin":
                if friend.canCast("heal"):
                    hero.command(friend, "cast", "heal" , hero)

```

---

<div class="post-metadata">

**Author:** ![stefan\_grecu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/stefan_grecu/32/20456_2.png) [@stefan\_grecu](https://discourse.codecombat.com/u/stefan_grecu)\
**Post date:** [January 7, 2021, 5:21pm UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/2 "2021-01-07T17:21:38Z")

</div>

@AnSeDra poti sa ma ajuti

---

<div class="post-metadata">

**Author:** ![Luke10](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/luke10/32/19892_2.png) [@Luke10](https://discourse.codecombat.com/u/Luke10)\
**Post date:** [January 7, 2021, 9:45pm UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/3 "2021-01-07T21:45:04Z")

</div>

> [@stefan\_grecu](#):
>
> i need help with this level

Could you explain more clearly what you are having trouble with and also post a screenshot of what happens when you run your code?

---

<div class="post-metadata">

**Author:** ![Code\_Master](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/code_master/32/16184_2.png) [@Code\_Master](https://discourse.codecombat.com/u/Code_Master)\
**Post date:** [January 7, 2021, 11:18pm UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/4 "2021-01-07T23:18:21Z")

</div>

@AnSeDra isn’t really active anymore, try asking @Chaboi_3000 or @Deadpool198

---

<div class="post-metadata">

**Author:** ![stefan\_grecu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/stefan_grecu/32/20456_2.png) [@stefan\_grecu](https://discourse.codecombat.com/u/stefan_grecu)\
**Post date:** [January 8, 2021, 8:41am UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/5 "2021-01-08T08:41:05Z")

</div>

when i run the code i die at the the beam-towers

---

<div class="post-metadata">

**Author:** ![stefan\_grecu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/stefan_grecu/32/20456_2.png) [@stefan\_grecu](https://discourse.codecombat.com/u/stefan_grecu)\
**Post date:** [January 8, 2021, 9:30am UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/6 "2021-01-08T09:30:13Z")

</div>

@Deadpool198 or @Chaboi_3000 can you help me

---

<div class="post-metadata">

**Author:** ![PeterPalov](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/peterpalov/32/45280_2.png) [@PeterPalov](https://discourse.codecombat.com/u/PeterPalov)\
**Post date:** [January 8, 2021, 10:23am UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/7 "2021-01-08T10:23:10Z")

</div>

> [@stefan\_grecu](#):
>
> ```python
> if fire.type == "tower":
> pass
> 
> ```

Why do you pass the tower?

---

<div class="post-metadata">

**Author:** ![stefan\_grecu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/stefan_grecu/32/20456_2.png) [@stefan\_grecu](https://discourse.codecombat.com/u/stefan_grecu)\
**Post date:** [January 8, 2021, 11:35am UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/8 "2021-01-08T11:35:14Z")

</div>

my hero stops moving and only spawns soldiers

---

<div class="post-metadata">

**Author:** ![stefan\_grecu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/stefan_grecu/32/20456_2.png) [@stefan\_grecu](https://discourse.codecombat.com/u/stefan_grecu)\
**Post date:** [January 8, 2021, 11:55am UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/9 "2021-01-08T11:55:01Z")

</div>

code

```python
while True:
    paladins = []
    enemies = hero.findNearestEnemy()
    greenFlag = hero.findFlag("green")
    blackFlag = hero.findFlag("black")
    violetFlag = hero.findFlag("violet")
    if violetFlag:
        friends = hero.findFriends()
        if friends:
            for friend in friends:
                if friend:
                    hero.command(friend, "move", violetFlag.pos)
    if greenFlag:
        hero.pickUpFlag(greenFlag)
    if blackFlag:
        hero.pickUpFlag(blackFlag)
        hero.attack(enemy)
    if hero.canCast("invisibility", hero):
        hero.cast("invisibility", hero)
    friends = hero.findFriends()
    for enemy in hero.findEnemies():
        friends = hero.findFriends()
        for friend in friends:
            e = friend.findNearestEnemy()
            if e:
                hero.command(friend, "attack", e)
    fire = hero.findNearestEnemy()
    if fire:
        if fire.type == "thrower":
            hero.findFriends()
            if friend.type == "archer":
                hero.command(friend, "attack", target)
        if fire.type == "beam-tower":
            if hero.canCast("chain-lightning", target):
                hero.cast("chain-lightning", target)
            hero.attack(enemy)
            pass
        if hero.gold > hero.costOf("archer"):
            hero.summon("archer")
    if hero.health < 3000:
        for friend in friends:
            if friend and friend.type == "paladin":
                if friend.canCast("heal"):
                    hero.command(friend, "cast", "heal" , hero)

```

problem ![dsjkfdgkjsdhf](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/0/1/01726aad33401272f962571edf334a8bb68d69d7.png)

---

<div class="post-metadata">

**Author:** ![PeterPalov](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/peterpalov/32/45280_2.png) [@PeterPalov](https://discourse.codecombat.com/u/PeterPalov)\
**Post date:** [January 8, 2021, 11:57am UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/10 "2021-01-08T11:57:39Z")

</div>

> [@stefan\_grecu](#):
>
> ```python
> fire = hero.findNearestEnemy()
> if fire:
> if fire.type == "thrower":
> hero.findFriends()
> if friend.type == "archer":
> hero.command(friend, "attack", target)
> if fire.type == "beam-tower":
> if hero.canCast("chain-lightning", target):
> hero.cast("chain-lightning", target)
> 
> ```

Yeah, the problem is here. You have to write `target = hero.findNearestEnemy()`  
Also, you have to write `friends = hero.findFriends()`, and then you have to write `for`, and only in it command your friends.

---

<div class="post-metadata">

**Author:** ![stefan\_grecu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/stefan_grecu/32/20456_2.png) [@stefan\_grecu](https://discourse.codecombat.com/u/stefan_grecu)\
**Post date:** [January 8, 2021, 12:00pm UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/11 "2021-01-08T12:00:38Z")

</div>

where do i need to write `for`?

---

<div class="post-metadata">

**Author:** ![PeterPalov](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/peterpalov/32/45280_2.png) [@PeterPalov](https://discourse.codecombat.com/u/PeterPalov)\
**Post date:** [January 8, 2021, 12:21pm UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/12 "2021-01-08T12:21:36Z")

</div>

After friends = hero.findNearestFroends().

---

<div class="post-metadata">

**Author:** ![stefan\_grecu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/stefan_grecu/32/20456_2.png) [@stefan\_grecu](https://discourse.codecombat.com/u/stefan_grecu)\
**Post date:** [January 8, 2021, 12:28pm UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/13 "2021-01-08T12:28:17Z")

</div>

what are froends?

---

<div class="post-metadata">

**Author:** ![stefan\_grecu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/stefan_grecu/32/20456_2.png) [@stefan\_grecu](https://discourse.codecombat.com/u/stefan_grecu)\
**Post date:** [January 8, 2021, 12:30pm UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/14 "2021-01-08T12:30:59Z")

</div>

you mean like this

```python
if fire:
        if fire.type == "thrower":
            friend = hero.findFriends() for
            if friend.type == "archer":
                hero.command(friend, "attack", fire)

```

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [January 8, 2021, 12:38pm UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/15 "2021-01-08T12:38:11Z")

</div>

@PeterPalov means like this:

```python
friends = hero.findFriends()
for friend in friends:
    if friend:
        #command your friends and everything else

```

---

<div class="post-metadata">

**Author:** ![stefan\_grecu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/stefan_grecu/32/20456_2.png) [@stefan\_grecu](https://discourse.codecombat.com/u/stefan_grecu)\
**Post date:** [January 9, 2021, 10:02am UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/16 "2021-01-09T10:02:57Z")

</div>

i tried but i die at the beam towers

---

<div class="post-metadata">

**Author:** ![stefan\_grecu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/stefan_grecu/32/20456_2.png) [@stefan\_grecu](https://discourse.codecombat.com/u/stefan_grecu)\
**Post date:** [January 14, 2021, 11:45am UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/17 "2021-01-14T11:45:58Z")

</div>

@PeterPalov , @abc and @Deadpool198 can you guys help me

---

<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 14, 2021, 11:48am UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/18 "2021-01-14T11:48:52Z")

</div>

Please could you post the very latest version of your code so I can see what’s going on. Thanks

---

<div class="post-metadata">

**Author:** ![stefan\_grecu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/stefan_grecu/32/20456_2.png) [@stefan\_grecu](https://discourse.codecombat.com/u/stefan_grecu)\
**Post date:** [January 14, 2021, 12:15pm UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/19 "2021-01-14T12:15:49Z")

</div>

@Deadpool198 this is my latest code:

```python
while True:
    paladins = []
    enemies = hero.findNearestEnemy()
    greenFlag = hero.findFlag("green")
    blackFlag = hero.findFlag("black")
    violetFlag = hero.findFlag("violet")
    if violetFlag:
        friends = hero.findFriends()
        if friends:
            for friend in friends:
                if friend:
                    hero.command(friend, "move", violetFlag.pos)
    if greenFlag:
        hero.pickUpFlag(greenFlag)
    if blackFlag:
        hero.pickUpFlag(blackFlag)
        hero.attack(enemy)
    if hero.canCast("invisibility", hero):
        hero.cast("invisibility", hero)
    friends = hero.findFriends()
    for enemy in hero.findEnemies():
        friends = hero.findFriends()
        for friend in friends:
            e = friend.findNearestEnemy()
            if e:
                hero.command(friend, "attack", e)
    fire = hero.findNearestEnemy()
    if fire:
        if fire.type == "thrower":
            pass
        while fire.health > 0:
            if hero.canCast("invisibility", hero):
                hero.cast("invisibility", hero)
            hero.attack(fire)
            hero.shield()
        if fire.type == "beam-tower":
            hero.command("archer", "attack", "beam-tower")
        if hero.gold > hero.costOf("archer"):
            hero.summon("archer")
    if hero.health < 3000:
        for friend in friends:
            if friend and friend.type == "paladin":
                if friend.canCast("heal"):
                    hero.command(friend, "cast", "heal" , hero)

```

---

<div class="post-metadata">

**Author:** ![Archipelago-Gold](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/archipelago-gold/32/18442_2.png) [@Archipelago-Gold](https://discourse.codecombat.com/u/Archipelago-Gold)\
**Post date:** [January 14, 2021, 6:39pm UTC](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420/20 "2021-01-14T18:39:14Z")

</div>

Did it work For you?

[Next page](https://discourse.codecombat.com/t/summits-gate-pls-help-me-python/26420.md?page=2)
