CS4 Lvl 21 Python Help

It’s been I while since I have been on codecombat because I am working on making a game and I don’t understand what to do on the level I am on. Any suggestions? Here is my code so far:


while True:
    coins = hero.findItems()
    coinIndex = 0
    nearest = None
    nearestDistance = 9999
    
    # Loop through all the coins to find the nearest one.
    while coinIndex < len(coins):
        coin = coins[coinIndex]
        coinIndex += 1
        distance = hero.distanceTo(coin)
        # If this coin's distance is less than the nearestDistance
        if distance < nearestDistance:
            # Set nearest to coin
            nearest = coin
            # Set nearestDistance to distance
            nearestDistance = distance
            hero.say(nearestDistance)
        if distance == nearestDistance:
            hero.moveXY(nearest.pos.x, nearest.pos.y)
    # If there's a nearest coin, move to its position. You'll need moveXY so you don't cut corners and hit a trap.

[Code removed by a moderator: Please don’t post successful solutions as it is counterproductive to the learning process]

@Bentley_Davidson please do not post solution codes here

moderation will be looking into this

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.