Need help on "Hoarding gold"


#1

This is my code when I run it it tells me this.

totalGold = 0
loop:
    "Coin" = self.findNearest(self.findItems())
    CoinPos = coin.pos #coin is not the variable name, you named it Coin
    x = CoinPos.x
    y = CoinPos.y
    self.moveXY(x, y)
    totalGold += coin.value #coin is not the variable name, you named it Coin

    totalGold += coin.value #You are adding the coin's value twice

    if totalGold >= 25:
        break #You just broke out of t<img src="/uploads/codecombat/original/2X/2/22c0332f6215c80c393e0b3abde33b8ee7a81ccf.PNG" width="194" height="131">he loop just to follow the rest of the code. Try placing  the last two pieces inside this "if" statement, before the break (this is not required, however it is more readable)
        self.moveXY(58, 33)
        self.say("I am done collecting gold.")

The error is saying “Assigning to rvalue”


#2

Here:

"Coin" = self.findNearest(self.findItems())

"Coin" should be coin (no quotes). The quotes make it a string. Strings are values, not references. You can only assign values to references, not values. References are usually in the form of variables and object properties/indexes.


#3

Okay, thank you. I already figured it out and forgot to close the conversation.