Assigning Rvalue


#1

Hi i am not able to find out the problem in my code
’ if 1 + 1 == 3: # ∆ Make this false.
hero.moveXY(5, 15) # Move to the first mines.

if 2 + 3 == 5: # ∆ Make this true.
hero.moveXY(15, 40) # Move to the first gem.

!= means “is not equal to”.

if 2 + 2 == 4: # ∆ Make this true.
hero.moveXY(25, 15) # Move to the second gem.

< means “is less than”.

if 2 + 2 < 5: # ∆ Make this true.
enemy = hero.findNearestEnemy()
hero.attack(enemy)

if 2 < 1: # ∆ Make this false.
hero.moveXY(40, 55)

if True 3 = 0: # ∆ Make this false.
hero.moveXY(50, 10)

if False 2 + 3 = 9: # ∆ Make this true.
hero.moveXY(55, 25)`


#2

Please format your code by surrounding it top and bottom with triple backticks ( ` )


#3
if 1 + 1 == 3:  # ∆ Make this false.
    hero.moveXY(5, 15)  # Move to the first mines.

if 2 + 3 == 5:  # ∆ Make this true.
	hero.moveXY(15, 40)  # Move to the first gem.

# != means "is not equal to".
if 2 + 2 == 4:  # ∆ Make this true.
	hero.moveXY(25, 15)  # Move to the second gem.
	
# < means "is less than".
if 2 + 2 < 5:  # ∆ Make this true.
    enemy = hero.findNearestEnemy()
    hero.attack(enemy)

if 2 < 1:  # ∆ Make this false.
	hero.moveXY(40, 55)

if True 3 = 0:  # ∆ Make this false.
	hero.moveXY(50, 10)

if False 2 + 3 = 9:  # ∆ Make this true.
	hero.moveXY(55, 25)

#4
if True 3 = 0:  # ∆ Make this false.
	hero.moveXY(50, 10)

Is not properly formatted code.

True is a keyword, 3 will be rendered as a number, = is the assignment-operator, and 0 is another number.

The simplest way to make True false would be to write it as False instead.

Further the rvalue error is a result of trying to assign a variable inside of an if-statement.

= is the assignment operator. It assigns something to something else.

== is a comparison (equality) operator, and checks if two things are equal.


#5

i solved it thanks for trying to help i appreciated that


#6

And what are === for?
To check is [1,53,235] equal to [1,53,235] and to compare with null?