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

**URL:** https://discourse.codecombat.com/t/solved-desert-combat-code-is-working-to-half-python-help/24582
**Category:** Level Help
**Created:** [October 2, 2020, 10:28am UTC](https://discourse.codecombat.com/t/solved-desert-combat-code-is-working-to-half-python-help/24582 "2020-10-02T10:28:29Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![paddok](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@paddok](https://discourse.codecombat.com/u/paddok)
#### Post date: [October 2, 2020, 10:28am UTC](https://discourse.codecombat.com/t/solved-desert-combat-code-is-working-to-half-python-help/24582/1 "2020-10-02T10:28:29Z")

</div>

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)  
> hero.say(“Attack!”)  
> ordersGiven + 1  
> while True:  
> enemy = hero.findNearestEnemy()  
> if ordersGiven == 5:  
> hero.attack(enemy)

---

<div class="post-metadata">

### Author: ![jka2706](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/jka2706/32/13636_2.png) [@jka2706](https://discourse.codecombat.com/u/jka2706)
#### Post date: [October 2, 2020, 10:59am UTC](https://discourse.codecombat.com/t/solved-desert-combat-code-is-working-to-half-python-help/24582/2 "2020-10-02T10:59:46Z")

</div>

Hi paddok,

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

```python
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](https://discourse.codecombat.com/t/essentials-how-to-post-format-your-code-correctly/15521).

Jenny

---

<div class="post-metadata">

### Author: ![GraySkayl007](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/grayskayl007/32/14563_2.png) [@GraySkayl007](https://discourse.codecombat.com/u/GraySkayl007)
#### Post date: [October 2, 2020, 1:12pm UTC](https://discourse.codecombat.com/t/solved-desert-combat-code-is-working-to-half-python-help/24582/3 "2020-10-02T13:12:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![098765432123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/098765432123/32/25850_2.png) [@098765432123](https://discourse.codecombat.com/u/098765432123)
#### Post date: [October 2, 2020, 1:45pm UTC](https://discourse.codecombat.com/t/solved-desert-combat-code-is-working-to-half-python-help/24582/4 "2020-10-02T13:45:17Z")

</div>

here @GraySkayl007  
[https://codecombat.com/play/level/desert-combat](https://codecombat.com/play/level/desert-combat)?

---

<div class="post-metadata">

### Author: ![GraySkayl007](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/grayskayl007/32/14563_2.png) [@GraySkayl007](https://discourse.codecombat.com/u/GraySkayl007)
#### Post date: [October 2, 2020, 1:59pm UTC](https://discourse.codecombat.com/t/solved-desert-combat-code-is-working-to-half-python-help/24582/6 "2020-10-02T13:59:28Z")

</div>

Okay, I see what’s wrong.

```python
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.

```python
ordersGiven += 1

```

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

Hope this helps.  
-Gray

---

<div class="post-metadata">

### Author: ![098765432123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/098765432123/32/25850_2.png) [@098765432123](https://discourse.codecombat.com/u/098765432123)
#### Post date: [October 2, 2020, 7:18pm UTC](https://discourse.codecombat.com/t/solved-desert-combat-code-is-working-to-half-python-help/24582/7 "2020-10-02T19:18:54Z")

</div>

does this solve your problem @paddok?

---

<div class="post-metadata">

### Author: ![TheOrbitals](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/theorbitals/32/28144_2.png) [@TheOrbitals](https://discourse.codecombat.com/u/TheOrbitals)
#### Post date: [October 3, 2020, 1:56am UTC](https://discourse.codecombat.com/t/solved-desert-combat-code-is-working-to-half-python-help/24582/8 "2020-10-03T01:56:07Z")

</div>

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

---

<div class="post-metadata">

### Author: ![paddok](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@paddok](https://discourse.codecombat.com/u/paddok)
#### Post date: [October 3, 2020, 9:35am UTC](https://discourse.codecombat.com/t/solved-desert-combat-code-is-working-to-half-python-help/24582/9 "2020-10-03T09:35:56Z")

</div>

Yes. Thanks for helping me guys :3

---

<div class="post-metadata">

### Author: ![cheddarcheese](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/cheddarcheese/32/22417_2.png) [@cheddarcheese](https://discourse.codecombat.com/u/cheddarcheese)
#### Post date: [October 3, 2020, 1:59pm UTC](https://discourse.codecombat.com/t/solved-desert-combat-code-is-working-to-half-python-help/24582/10 "2020-10-03T13:59:13Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)
#### Post date: [October 5, 2020, 6:23am UTC](https://discourse.codecombat.com/t/solved-desert-combat-code-is-working-to-half-python-help/24582/11 "2020-10-05T06:23:06Z")

</div>

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