[SOLVED] I am stuck on "Shine getter"

Whenever I run my code it returns that it cannot read property ‘0’ of undefined for line coins = hero.findItems()

while True:
    
    coins = hero.findItems()
    coinIndex = 0 
    while coinIndex < len(coins):
        coin = coin[coinIndex]
        if coin.value == 3:
            pos = coin.pos
            x = pos.x
            y = pos.y
            hero.moveXY(x, y)
    coinIndex += 1

the coinIndex+=1 is outside of the while loop

Also you said coin = coin[coinIndex]

Thanks. It worked great.

Could you please help me with Shine Getter?
This is my 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.
        pos = coin.pos
        x = coin.pos.x
        y = coin.pos.y
        hero.moveXY(x, y)
        coinIndex += 1
        pass
        

It says: Code never finished. It’s either really slow or has an infinite loop.

Try using hero.findNearestItem(), then check if coin value is 3.
-Lydia
P.S. Welcome to the forum! :partying_face: :partying_face:

1 Like

Figured it out! Thanks @Lydia_Song!

Welcome to the forum @TinyGoliath06 :partying_face:

You’re welcome! Congrats on solving it! :partying_face: :partying_face: