# Codecombat Savren Road

**URL:** <https://discourse.codecombat.com/t/codecombat-savren-road/19751>\
**Category:** Uncategorized\
**Created:** [December 4, 2019, 7:37pm UTC](https://discourse.codecombat.com/t/codecombat-savren-road/19751 "2019-12-04T19:37:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![13196](https://avatars.discourse-cdn.com/v4/letter/1/a87d85/32.png) [@13196](https://discourse.codecombat.com/u/13196)\
**Post date:** [December 4, 2019, 7:37pm UTC](https://discourse.codecombat.com/t/codecombat-savren-road/19751/1 "2019-12-04T19:37:25Z")

</div>

I have a problem with my code, I’m not sure what is wrong.  
‘’’  
while True:  
# If there’s an enemy, attack.  
enemy = hero.findNearestEnemy()  
hero.posx = x  
hero.posy = y  
x = x+3  
y = y+3  
if enemy:  
hero.attack(enemy)  
pass  
else:  
hero.moveXY(x, y)  
pass  
# Else, keep moving up and to the right.  
pass  
‘’’  
thanks

---

<div class="post-metadata">

**Author:** ![13196](https://avatars.discourse-cdn.com/v4/letter/1/a87d85/32.png) [@13196](https://discourse.codecombat.com/u/13196)\
**Post date:** [December 4, 2019, 7:38pm UTC](https://discourse.codecombat.com/t/codecombat-savren-road/19751/2 "2019-12-04T19:38:42Z")

</div>

```python
while True:
    # If there's an enemy, attack.
    enemy = hero.findNearestEnemy()
    hero.posx = x
    hero.posy = y
    x = x+3
    y = y+3
    if enemy:
        hero.attack(enemy)
        pass
    else:
        hero.moveXY(x, y)
        pass
    # Else, keep moving up and to the right. 
    pass

```

---

<div class="post-metadata">

**Author:** ![brooksy125](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brooksy125/32/9966_2.png) [@brooksy125](https://discourse.codecombat.com/u/brooksy125)\
**Post date:** [December 5, 2019, 4:16am UTC](https://discourse.codecombat.com/t/codecombat-savren-road/19751/3 "2019-12-05T04:16:10Z")

</div>

Looks like the x and y variables are not being assigned correctly.

```python
x = hero.pos.x #variable on left and value on right

```

---

<div class="post-metadata">

**Author:** ![13196](https://avatars.discourse-cdn.com/v4/letter/1/a87d85/32.png) [@13196](https://discourse.codecombat.com/u/13196)\
**Post date:** [December 5, 2019, 2:25pm UTC](https://discourse.codecombat.com/t/codecombat-savren-road/19751/4 "2019-12-05T14:25:57Z")

</div>

That was the problem, thanks. But shouldn’t the order not matter since there is a equal sign?

---

<div class="post-metadata">

**Author:** ![RiceRunner](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ricerunner/32/38852_2.png) [@RiceRunner](https://discourse.codecombat.com/u/RiceRunner)\
**Post date:** [December 5, 2019, 2:53pm UTC](https://discourse.codecombat.com/t/codecombat-savren-road/19751/5 "2019-12-05T14:53:52Z")

</div>

it may have been that you needed to assign a value to x or find out what x is in order for it to work  
I could be wrong though 😄 👍

---

<div class="post-metadata">

**Author:** ![brooksy125](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/brooksy125/32/9966_2.png) [@brooksy125](https://discourse.codecombat.com/u/brooksy125)\
**Post date:** [December 5, 2019, 3:29pm UTC](https://discourse.codecombat.com/t/codecombat-savren-road/19751/6 "2019-12-05T15:29:22Z")

</div>

The one main rule for Python variables is which side of the = sign.

```python
variable_name = "value being assigned"

```

Some other languages you have to declare the variable and sometimes it’s type before you can even us it.

JavaScript

```javascript
var variable_name = "value being assigned"

```
