Sand snake level help

i need help
my character just stays still and nothing happens

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

can u show us ur code?

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 coin.distance < nearestDistance:
            # Set nearest to coin
            nearest = coin
            # Set nearestDistance to distance
            nearestDistance = distance
            
            # If there's a nearest coin, move to its position. You'll need moveXY so you don't cut corners and hit a trap.
            hero.moveXY(distance.pos.x, distance.pos.y)

i have also changed distance with coin and it didnt work

Your problem is here

you need to change that to

if distance < nearestDistance:
hero.moveXY(coin.pos.x, coin.pos.y)

i don know what to put here instead of coin/distance and i tried both and neither worked

Change the coin to distance.

Screenshot 2021-04-02 9.54.51 PM
it says this

Post your code
29-0ekifpo

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
            
            # If there's a nearest coin, move to its position. You'll need moveXY so you don't cut corners and hit a trap.
            hero.moveXY(distance.pos.x, distance.pos.y)

Sorry. the moveXY one should be nearest.

i still blow up and it is just like the coin version

Please post your code again.

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
            
            # If there's a nearest coin, move to its position. You'll need moveXY so you don't cut corners and hit a trap.
            hero.moveXY(nearest.pos.x, nearest.pos.y)

do you have the mimic pet equiped

no i dont do i need to

Welp. I cant help anymore.

why do i need a mimic pet

No.

i already passed the level