Mountain mercenaries level help[SOLVED]

I am stuck in it. I can’t figure out the loop in the if enemy:

Could you please post a picture of what your code currently looks like? Thanks

1 Like

solderCount = 0
while True:
    # Move to the nearest coin.
    # Use move instead of moveXY so you can command constantly.
    coin = hero.findNearestItem()
    # If you have funds for a soldier, summon one.
    if > hero.costOf("soldier"):
        solderCount = solderCount + 1
    enemy = hero.findNearest(hero.findEnemies())
    if enemy:
        soldiers = hero.findFriends()
        soldierIndex = 0
        soldier = soldiers[soldierIndex]
        # Loop over all your soldiers and order them to attack.
        while *soldierIndex < solderCount* :
            enemy = hero.findNearest(hero.findEnemies())
            hero.command(soldier, "attack", enemy)
            soldierIndex = soldierIndex + 1
            soldier = soldiers[soldierIndex]
            # Use the 'attack' command to make your soldiers attack.
            #hero.command(soldier, "attack", enemy)

the code in ** is the part I am not sure about.

What I would suggest doing is removing the “solderCount” variable. You don’t actually need it if you change this issue. The issue with that line that you are not sure about is this part:

What you should use instead is: len(soldiers)
Hope this helps!

1 Like

Thanks! (20 characters)

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.