[SOLVED] Help Cloudrip Commander Codecombat Python

thanks its working now

1 Like

No problem! And congratulations for completing the level! :partying_face: :grin:

I am stuck too but for me it is the opposite my soldiers move but not me!
well i do move but only like 10 meters an then it shows an error here is what is says


and here is my 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})
    soldierIndex +=1
    # Go join your comrades!
    hero.move({'x': 50, 'y': 40})

can someone pls help me?

the soldiers = hero.findFriends() and soldierIndex = 0 doesn’t need to be into the while true loop.

it is not in a while loop

it says the problem is in this linre

hero.command(soldier, "move", {"x": 50, "y": 40})

oh ok(20 chars))))))))))))))))

so i don’t get it …

that line is correct try resubmitting

it is in running i have not submitted it yet

i will reload and try again

no actually you need to put if soldier: after the command then else put break after it

I did something and now i and one soldier moves

like this
if soldier:
hero.command(soldier, “move”, {“x”: 50, “y”: 40})
soldierIndex +=1
else:
break

i mean
if soldier:
hero.command(soldier, “move”, {“x”: 50, “y”: 40})
soldierIndex +=1
else:
break
sorry cannot format

I GOT IT! thank you very much for helping

np(20) and congrats for finishing the lvl

Try if soldier:
Dima

1 Like