Continuous Alchemy Help!

I’m currently stuck on the level Continuous Alchemy and I keep getting the error message “Assigning to rvalue” please help me!

Please include your code, formatted with code tags for easy use. Be sure to read the FAQ for information on how to do that.

im guessing that you put = instead of == ,judging from the error message.

@Serg Sorry, here’s the code.

# Race munchkins to the water distilled by Omarn Brewstone!
# The continue statement is powerful for managing complicated logic.
# When the program uses the continue statement, the rest of the loop is skipped.
# However, unlike with "break", the loop repeats instead of stopping.
# Use "continue" to verify the conditions of the ambush.
while True:
    enemy = hero.findEnemies()
    item = hero.findItems()
    firstItem = item[0]
    firstEnemy = enemy[0]
    # If there is no enemy, continue out of the loop.
    if not firstEnemy:
    # If there is an enemy, but no item, ask for a potion and continue out of the loop.
    if not firstItem:
        hero.say("Give me a drink!")
    # Use an if-statement to check the item's type. If the type is "poison", continue out of the loop.
    if firstItem = hero.findByType("poision"):
    # If it is not, the potion must be a bottle of water, so walk to it and return to the starting position!
    if not firstItem = hero.findByType("poision"):
        hero.moveXY(item.pos.x, item.pos.y)

You are using single = inside of a conditional (if-statement).

You cannot do if a = b:, but instead might want to do if a == b:.

Further, it is unclear what you’re actually trying to do. Remember how to check the type of an enemy in the forest?

if enemy.type == "munchkin":

You don’t need to use a method of the hero to do it. hero.findByType returns all of that type.

It might help to reload the code from scratch, since it looks like you’ve done further changes than just that. Some things I can see:

item = hero.findNearest(hero.findItems()) #  This is a better way of doing:
# item = hero.findItems()[0] # unless index matters.

Also you spelt poison wrong.

Thanks Serg I use the [quote=“Serg, post:5, topic:7469”]
em = hero.findNearest(hero.findItems()) # This is a better way of doing:

item = hero.findItems()[0] # unless index matters.


Because that’s the only way I know how to find an item or enemy with glasses that don’t have the findenemy command

Why do I have to use two = I’ve been using one when one works just fine?

I’m unsure of where single = may work! Can you provide some examples of where you were able to accomplish this?

= is the assignment operator, that is, it ‘assigns’ a value to another value in your code.

a = "Hello!"
# a is now the string "Hello!".

== is the equality operator, that is, it checks two values to see if they are ‘equal’.

if c == 5:
    # Code inside this block only runs when c is the number 5.

When you say:

if c = 5:
    # Depending on this language, this will either always run, or give an error.
    # Since you are assigning in a conditional statement, it is going to try to evaluate 5, which is 'true'-like.
if d = 0:
    # This would probably not ever run, since 0 is often 'false'-like.

oh thanks Serg I didn’t know that two == works like its own if command, thanks for that little bit of info! :smile: :smile: :smile: