Help With Shine Getter

So I’ve been stuck on the level Shine Getter in the Desert World, and I need some help.
So, I’m not sure what’s wrong with my code, but if anyone could help me out, I would appreciate it.
My code:

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

Your while-loop entails while coinIndex > len(coins):. The problem is, coinIndex is zero, and therefore is never greater then the amount of coins. I don’t suppose you meant while coinIndex < len(coins):?

Then I just get a “Hard Execution Limit of 3 Million”

Your indentations are also a little mixed up. If my assumptions are correct, you only increment coinIndex when you pick up a gold coin. This should not be. You want to loop over all coins.

Just tried it when you find a gold coin, not when you walk over it, and it worked. Thanks for your help

Lol I just got the 100 levels achievement and got 1,000 gems, too. :grinning:

Excuse me, what is wrong with my code?

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

while True:
coins = hero.findItems()
coinIndex = 0

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

First, your if conditional statement should be inside your while loop. It appears that it is inside the while True: loop, but not inside the while coinIndex < len(coins): loop where it should be.

Second, you are not incrementing. You must increment coinIndex.