I need help with Shine Getter

my code

`coinIndex = 0
while True:
    coins = hero.findItems()
    
    
    # Wrap this into a loop that iterates over all coins.
    while coinIndex < len(coins):
        coin = coins[coinIndex]
        # Gold coins are worth 3.
        if coins.value == 3:
            # Only pick up gold coins.
            hero.moveXY(coin.pos.x, coin.pos.y)
        coinIndex += 1
    pass
`
```it says unkown unary operator:UADD

it’s coin.value not coins.value. Coins is not defined

Actually, coins is defined, but as an array, so does not have a .value property. Otherwise, you are correct Epic. :wink:

so coin = coin[coinIndex]

so i tried the code with

coin = coin[coinIndex]

instead of

coin = coins[coinIndex]

and it dosen’t work the hero won’t move for me.

Actually, the coin definition was correct the way it was: coin = coins[coinIndex]
The problem is with:

        # Gold coins are worth 3.
        if coins.value == 3:

‘coins’ is the array holding all of the coins that were found. As such, it does not have a .value property. ‘coin’ on the other hand is an individual item and it does have a .value property…

i did your changes but it still says:it says unknown unary operator:UADD

Could we see your new code please.
Danny

ok
Code:


while True:
    coins = hero.findItems()
    coinIndex = 0
    
    # Wrap this into a loop that iterates over all coins.
    while coinIndex < len(coins):
        coin = coins[coinIndex]
        # Gold coins are worth 3.
        if coin.value == 3:
            # Only pick up gold coins.
            hero.moveXY(coin.pos.x, coin.pos.y)
            pass
        coinIndex =+1

Aha! What’s this:

A simple typo (hopefully :grin:)

a is a simple typo! (yay :star_struck: :partying_face:)

thanks for the help Deadpool198/Danny, dedreousHelpful User, EpicCoder999

1 Like