items=self.findItems()
itemsIndex=0
if items:
while self.gold < 20:
item=items[itemsIndex]
if item:
self.moveXY(item.pos.x, item.pos.y)
itemsIndex += 1
You go through the items array once (the items you can initially see at the beginning of the level), then you are done. If you can’t get 20 gold with those items, you’ll start looping forever. But not all the coins spawn at the very beginning of the level.
Probably you want to refresh items = self.findItems() each time through your while-loop, and then use item = findNearest(items) to get the right one to go after.
Thanks for your help and sorry for the late answer, I have been away.
I played further and learnt some new tricks.
Now all seems to work as intended, which is the main point. Running the code I succeeded but when I submitted it I lost hahaha I will try with better equipment