[SOLVED] Help Cloudrip Commander Codecombat Python

# Summon some soldiers, then direct them to your base.

# Each soldier costs 20 gold.
while hero.gold > hero.costOf("soldier"):
    hero.summon("soldier")
    
soldiers = hero.findFriends()
soldierIndex = 0
# Add a while loop to command all the soldiers.
while soldiers > 0:
    soldier = soldiers[soldierIndex]
    hero.command(soldier, "move", {"x": 50, "y": 40})

# Go join your comrades!
hero.moveXY(51, 41)

I need help on Cloudrip Commander, only my hero moves and not the soldiers

Never mind, I solved it.

Wow did you did it ?

Hi @Kairos and welcome to the forum! :partying_face:

Why? Do you also need help at this level? If so, tell us your code, but format it like now it is described here:
1 Like

it isn’t working for me I need help

Hi liam_cutts, welcome to Discourse!

Can you post your code, and give a bit of info about what isn’t working?

There’s info on how to format your code at:

https://discourse.codecombat.com/t/essentials-how-to-post-format-your-code-correctly/15521/2

1 Like

Hi @liam_cutts and welcome to the forum! :partying_face:

Can you send us your code formated how it is described here and tell us what is wrong with the code?

Summon some soldiers, then direct them to your base.

Each soldier costs 20 gold.

while hero.gold > hero.costOf(“soldier”):
hero.summon(“soldier”)

soldiers = hero.findFriends()
soldierIndex = 0

Add a while loop to command all the soldiers.

while True:
soldier = soldiers[soldierIndex]
hero.command(soldier, “move”, {“x”: 50, “y”: 40})

hero.moveXY(51, 41)

it only moves my hero and one soldier

Try to format it how it is described here so we will be able to help you.

can you show me the right code for it

for cloudrip commander

can you show the right code

No, here we do not post solutions. Try to send your code property formated so we can help you figure out the error.

I don’t know how to do it

type or paste code here
# Summon some soldiers, then direct them to your base.

# Each soldier costs 20 gold.
while hero.gold > hero.costOf("soldier"):
    hero.summon("soldier")
    
soldiers = hero.findFriends()
soldierIndex = 0
# Add a while loop to command all the soldiers.
while True:
    soldier = soldiers[soldierIndex]
    hero.command(soldier, "move", {"x": 50, "y": 40})
    soldierIndex+1
    hero.moveXY(51, 41)

Here you shouldn’t have a while true loop, but a while loop that is executing until soldierIndex == len(soldiers).
And try to put this line

Outside the while loop.
Do you need any more assistance at this level?

can you show what I do for the while loop in code

So instead of that something like this:

while soldierIndex < len(soldiers):

And here is an issue. Try to put this instead.

soldierIndex += 1

Do you need any more assistance at this level?