[SOLVED]Shine Getter Python Help

Hello~ I’m on Shine Getter(https://codecombat.com/play/level/shine-getter?) and I can’t seem to understand exactly what is wrong with my code :confused:.

# To grab the most gold quickly, just go after gold coins.

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

It says coins isn’t defined, but I don’t know where I need to define coins. :thinking:
-Rachel

im pretty sure you define before but @AnSeDra would know

1 Like

I looked at the hints, and now I’m left with this code:

# To grab the most gold quickly, just go after gold coins.

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

But it still says coins isn’t defined :frowning:
-Rachel

1 Like

try flipping the

coinIndex = 0
hero.findNearestItem()
2 Likes

and you dont need this

pos = coin.pos
            x = pos.x
            y = pos.
2 Likes

for this

hero.moveXY(x, y)

put

hero.moveXY(coin.pos.x, coin.pos.y)
2 Likes

I think I figured out where the “coin” isn’t defined, and I was able to complete the level :heart:. Thanks for your help!
-Rachel

2 Likes

your welcome i hlp people whenever i can :smiley: (if i can)

2 Likes

lol…I came in too late :smiley:

3 Likes

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.