[Solved] The Bane of Soldiers help (Python)

while True:
    enemies = hero.findEnemies()
    enemy = hero.findNearest(enemies)
    friends = hero.findFriends()
    # Send the first soldier of the friends array towards the enemy.
    hero.command(friends[0], "move", {'x': 60, 'y': 34})
    # i in range(1, n) starts the index at the second element!
    for i in range(1, len(friends)):
        friend = friends[i]
        # Command the remaining soldiers to run away!
        hero.command(friends[i], "move", {"x": 29, "y": 34})

So I’m trying to send the friend[0] first towards the bombs, but they all start running away. How can I fix this?
I also get an error message saying

Welcome‌ ‌welcome‌ ‌to‌ ‌the‌ ‌forum!‌ ‌It‌ ‌is‌ ‌a‌ ‌lovely‌ ‌place‌ ‌where‌ ‌you‌ ‌can‌ ‌share‌ ‌all‌ ‌kinds‌ ‌of‌ stuff‌ ‌(appropriate‌ ‌of‌ ‌course),‌ ‌share‌ ‌bugs,‌ ‌and‌ ‌even‌ ‌get‌ ‌assistance‌ ‌for‌ ‌code!‌ ‌We‌ ‌suggest‌ ‌that‌ ‌you‌ ‌review‌ ‌this‌‌ topic‌ ‌which‌ ‌shows‌ ‌all‌ ‌essentials‌ ‌of‌ ‌this‌ ‌board!‌ ‌And‌ ‌we‌ ‌suggest‌ ‌you‌ ‌review‌ this topic‌ ‌which‌ ‌shows‌ ‌how‌ ‌to‌ ‌post‌ ‌your‌ ‌code‌ ‌correctly!‌ ‌Thanks!!‌ ‌ :partying_face: :partying_face:
Could you please send the link to the level?


Hello and welcome to the forum! This is a cosy forum where you can do all sorts of things from share memes to get help with levels. We hope you enjoy your time here in this wonderful place!

@Lydia_Song here is the link: https://codecombat.com/play/level/the-bane-of-soldiers

@CryptiCrystal you need to find and define the first friend and command it to move to the enemy.


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