I’ve tried everything and nothing works plz help anything would be nice

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

Umm… he does in here coin = coins[coinIndex] his problem is he is defining pos wrong, The pos class/function is already predefined by the codecombat source code. Delete pos=coin.pos and it should work.

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

I realized one mistake, I forgot to put coins = self.findItems() above while len(coins) < 3: here is my code nowwhile True: coins = self.findItems() while len(coins) < 3: coinIndex = 0 # Wrap this into a loop that iterates over all coins. coin = coins[coinIndex] # Gold coins are worth 3. if coin.value == 3: # Only pick up gold coins. pos=coin.pos x = coin.pos.x y = coin.pos.y self.moveXY(x, y)

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

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

while True:
coins = self.findItems() # use hero instead of self, don't be sure they are the same thing
coinIndex = 0
hero.say('len(coins) = ' + len(coins)) # picture added below
# while len(coins) < 3: # this will never be true
while # add code here to compare coinIndex with len(coins)
# Wrap this into a loop that iterates over all coins.
coin = coins[coinIndex]
# Gold coins are worth 3.
if coin.value == 3:
# Only pick up gold coins.
# pos=coin.pos # comment this line pos isn't same as pos in x = coin.pos.x or coin.pos.y
# it's a new variable you don't use
x = coin.pos.x
y = coin.pos.y
self.moveXY(x, y)
# increment somewhere in the second while loop coinIndex to iterate through all the coins

I added hero.say('len(coins) = ’ + len(coins)) for debug and this is the picture: