[SOLVED] Desert Combat Code is working to half (Python Help)

Hello Guys,
i dont understand whats wrong with my code. The Soldiers are attacking the ogre but my hero is just running into the Rocks. Here´s my code:

ordersGiven = 0
while ordersGiven < 5:
hero.moveXY(hero.pos.x, hero.pos.y - 10)
ordersGiven + 1
while True:
enemy = hero.findNearestEnemy()
if ordersGiven == 5:

Hi paddok,

I think you just need to put an = into this line:

ordersGiven + 1

However I can’t tell if your indentation is correct - if you’re still having problems can you repost your code with it formatted according to the instructions here.


Hello @paddok,
Can you send the link to this level?

here @GraySkayl007

Okay, I see what’s wrong.

ordersGiven + 1

Here you are just getting the amount of ordersGiven plus one, and not doing anything with it. What you need to do is add and assign, or something more like this.

ordersGiven += 1

Here the plus adds one to the variable, and the equals assigns that new amount to the variable.

Hope this helps.


does this solve your problem @paddok?

Maybe because he didn’t format the code correctly, there might be some indentation problems instead
~ Orb

1 Like

Yes. Thanks for helping me guys :3


click the tick box next to the reply that helped you most.

1 Like

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