What wrong in this code? Help


#1

Hi, im from Russia and i dont finish this riddle. Help me please. This is my 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
What wrong?


#2

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


#3

Thank you very much. Really this block was forgot me.