I can’t figure out why this is not working

```
loop:
coins = self.findItems()
coinIndex = 0
nearest = None
nearestDistance = 9999
# Loop through all the coins to find the nearest one.
while coinIndex < len(coins):
# while the coinindex (0) is less than the number of coins
coin = coins[coinIndex]
# coin is the items in the coinindex
coinIndex += 1
# add 1 to the coinindex
distance = self.distanceTo(coin)
#the distance is my distance to the items in the coin index
if distance < nearestDistance:
# if my distance to the coin is less than the nearest distance
nearest = coin
# nearest becomes the items in the coinindex
nearestDistance = distance
#nearestdistance becomes the distance to the coins in the coin index
if nearest:
#if theres an item in the coin index
self.moveXY(nearest.pos.x, nearest.pos.y)
#move to the item
```