# \[SOLVED\] Two flowers stuck

**URL:** <https://discourse.codecombat.com/t/solved-two-flowers-stuck/17058>\
**Category:** Level Help\
**Created:** [January 9, 2019, 12:16pm UTC](https://discourse.codecombat.com/t/solved-two-flowers-stuck/17058 "2019-01-09T12:16:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trai\_Leammookda](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/trai_leammookda/32/8419_2.png) [@Trai\_Leammookda](https://discourse.codecombat.com/u/Trai_Leammookda)\
**Post date:** [January 9, 2019, 12:16pm UTC](https://discourse.codecombat.com/t/solved-two-flowers-stuck/17058/1 "2019-01-09T12:16:23Z")

</div>

```python
# If the peasant is damaged, the flowers will shrink!

def summonSoldiers():
    if hero.gold >= hero.costOf("soldier"):
        hero.summon("soldier")
    

# Define the function: commandSoldiers
def commandSoldiers():
    friends = hero.findByType("soldier")
    for friend in friends:
        enemy = hero.findNearestEnemy()
        if enemy:
            hero.command(friend, "attack", enemy)
            # Define the function: pickUpNearestCoin
def pickUpNearestCoin():
    item = hero.findNearestItem()
    if item:
        hero.move(item.pos)
peasant = hero.findByType("peasant")[0]

while True:
    castable = hero.canCast("haste", self)
    enemy = hero.findNearestEnemy()
    castable2 = hero.canCast("chain-lightning", enemy)
    
    if castable:
        hero.cast("haste", self)
    else:
        hero.resetCooldown("haste")
    summonSoldiers()
    # commandSoldiers()
    # pickUpNearestCoin()
    commandSoldiers()
    pickUpNearestCoin()

```

How do I solve this, Hector keep dying but I think my code is correct. Can someone help me?

---

<div class="post-metadata">

**Author:** ![Chaboi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chaboi/32/9999_2.png) [@Chaboi](https://discourse.codecombat.com/u/Chaboi)\
**Post date:** [January 10, 2019, 12:22am UTC](https://discourse.codecombat.com/t/solved-two-flowers-stuck/17058/2 "2019-01-10T00:22:30Z")

</div>

Try removing the casting part.

---

<div class="post-metadata">

**Author:** ![Trai\_Leammookda](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/trai_leammookda/32/8419_2.png) [@Trai\_Leammookda](https://discourse.codecombat.com/u/Trai_Leammookda)\
**Post date:** [January 10, 2019, 10:57am UTC](https://discourse.codecombat.com/t/solved-two-flowers-stuck/17058/3 "2019-01-10T10:57:40Z")

</div>

Thanks! Maybe that will work.
