Shine Getter help - Python


#1

I’m really stuck on this level. Tried about every possible way using other posts but I was unable to get my character to get anything more than 3 coins. Now he just stands in the middle. Any help? thanks.


coins = self.findItems()
coinIndex = 0

while coinIndex < len(coins):    
    if coin.value == 3:
        posc = coin.pos
        cx = posc.x
        cy = posc.y
        self.moveXY(cx, cy)
    coinIndex += 1

#2

Im not going to give you the exact answer but, you have to use arrays


#3

Try to read your code out loud.

While coinIndex is smaller than the length of coins, and if the value of coin… wait, which coin?

You didn’t define what coin should contain.
You can simply do

coin = coins[coinIndex]

#4

That was my next thing after reading some other games I completed. However I cannot get back into this specific one, it crashes on loading. Doesn’t give the option to comment out code like before. I must have messed something up with it.

Edit: Nick fixed the crash.


#5

it doesn’t work for me. it just says “hard execution of 1000000 needed” :confused:.


#6

Help us help you. Without your code I can’t tell you what exactly is causing the HEL-problem.


#7

Plz help me with my code. I don’t get what I did wrong.

loop {
var coins = this.findItems();
var coinIndex = 0;

// Wrap this into a loop that iterates over all coins.
while (coinIndex < coins.length) {
    var coin = coins[coinIndex];
    // Gold coins are worth 3.
    if (coin.value == 3) {
        // Only pick up gold coins.
        this.moveXY(coin.pos.x, coin.pos.y);
    }
    coinIndex += 1;
}

}