# Why I get Error: assigning to rvalue?

**URL:** <https://discourse.codecombat.com/t/why-i-get-error-assigning-to-rvalue/2887>\
**Category:** Uncategorized\
**Created:** [February 27, 2015, 1:24am UTC](https://discourse.codecombat.com/t/why-i-get-error-assigning-to-rvalue/2887 "2015-02-27T01:24:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikeltor](https://avatars.discourse-cdn.com/v4/letter/v/b487fb/32.png) [@Vikeltor](https://discourse.codecombat.com/u/Vikeltor)\
**Post date:** [February 27, 2015, 1:24am UTC](https://discourse.codecombat.com/t/why-i-get-error-assigning-to-rvalue/2887/1 "2015-02-27T01:24:47Z")

</div>

Hello all!  
I have the code like above and get the error “assigning to rvalue”. Why?

```
if 1 + 1 + 1 = 3:
    self.moveXY(0, 16) # Обход первой группы мин.
    self.moveXY(0, 12)
    self.moveXY(7, 12)
    self.moveXY(0, 12)
    self.moveXY(0, 16)
if 2 + 2 == 4:
	self.moveXY(15, 40) # Передвижение к первому самоцвету.
if 2 + 2 == 4:
	self.moveXY(25, 15) # Передвижение к второму самоцвету.
if 2 + 2 > 3:
    enemy = self.findNearestEnemy()
    self.attack(enemy)
if 2 == 4:
	self.moveXY(40, 55)
if False:
	self.moveXY(50, 10)
if True:
	self.moveXY(55, 25)
```

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [February 27, 2015, 1:29am UTC](https://discourse.codecombat.com/t/why-i-get-error-assigning-to-rvalue/2887/2 "2015-02-27T01:29:29Z")

</div>

Use `==` instead of `=` on the first line. `=` is a variable assigment, whereas `==` is an equality check. (This is one of the worst mistakes in programming operator choices ever made, but now almost every language has it, so we have to live with it.)

---

<div class="post-metadata">

**Author:** ![Vikeltor](https://avatars.discourse-cdn.com/v4/letter/v/b487fb/32.png) [@Vikeltor](https://discourse.codecombat.com/u/Vikeltor)\
**Post date:** [February 27, 2015, 2:02am UTC](https://discourse.codecombat.com/t/why-i-get-error-assigning-to-rvalue/2887/3 "2015-02-27T02:02:23Z")

</div>

Ouh! Thank you!  
I can’t find it because interpreter point to other line.  
The stupid level with stupid “if” You can remove it all and that would be winning code.

Can you told me. I catch the helm and the sword in this level (gems-or-death) but can’t find this items.  
Have I really get them?

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [February 27, 2015, 10:33pm UTC](https://discourse.codecombat.com/t/why-i-get-error-assigning-to-rvalue/2887/4 "2015-02-27T22:33:20Z")

</div>

Yup, you could just delete the `if` statements around the parts you wanted to actually fire. Most players will enjoy the `if` practice, though.

Nah, the sword and helmet are just there for decoration, and unfortunately they move when you walk next to them. Gotta fix that!

---

<div class="post-metadata">

**Author:** ![ja200fsfa](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@ja200fsfa](https://discourse.codecombat.com/u/ja200fsfa)\
**Post date:** [May 13, 2017, 6:49am UTC](https://discourse.codecombat.com/t/why-i-get-error-assigning-to-rvalue/2887/5 "2017-05-13T06:49:32Z")

</div>

Thanks for helping nick!

[![](https://discuss-assets.s3.amazonaws.com/original/3X/d/0/d04329105596bb49fb991c9bf2e3f70cec4e2778.png)](https://www.clippp.com/)

---

<div class="post-metadata">

**Author:** ![\_TD\_RodYT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/_td_rodyt/32/6285_2.png) [@\_TD\_RodYT](https://discourse.codecombat.com/u/_TD_RodYT)\
**Post date:** [May 13, 2017, 4:37pm UTC](https://discourse.codecombat.com/t/why-i-get-error-assigning-to-rvalue/2887/6 "2017-05-13T16:37:39Z")

</div>

Please Do not bring up dead topics as they will bring the topic up to the front page. Read the FAQ before posting, as this post has been left untouched for 2 Years.

> [@FAQ - Check Before Posting](https://discourse.codecombat.com/t/faq-check-before-posting/1027):
>
> Check This Awesome FAQ Before Posting … you know it’s sweet stuff! Might save your life some day. [I need help with my code!](#code-help) Check each level’s help guide for common tips If a level is too hard, try a different hero or different items Common error messages and how to debug them Post your code with radiant, harmonious formatting Personal coding help from the CodeCombat staff [The game is not working!](#not-working) It crashes It doesn’t load It’s slow The graphics aren’t showing up [Can you please fix …](#bugs)
