What wrong in this code? Help

Hi @Yarikhp,

Always code in radiant, harmonious formatting according to FAQs to make reading and analyzing it easy for everybody.

Your code:

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

I think you have forgotten to augment the index for the while loop. So try adding:

coinIndex = coinIndex + 1 #think where to add this line, check and post back if it works

at the appropriate place.

Enjoy

1 Like