# How do you do the level double cheek?[SOLVED]

i was working on this level and one of my code lines it says “try hero.pos”

here is my code

``````# First, defeat 6 ogres.
# Then collect coins until you have 30 gold.

# This variable is used for counting ogres.
defeatedOgres = 0
coin = hero.findNearestItem()

# This loop is executed while defeatedOgres is less than 6.
while defeatedOgres < 6:
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
defeatedOgres += 1
else:
hero.say("Ogres!")

# Move to the right side of the map.
hero.moveXY(49, 36)

# This loop is executed while you have less than 30 gold.
while hero.gold < 30:
# Find and collect coins.
hero.moveXY(coin.pos.x, coin.pos.y)          this is the line with the problem
# Remove this say() message.
hero.say("I should gather coins!")

# Move to the exit.
hero.moveXY(76, 32)
``````
1 Like

You have to find the nearest item within the while loop and define it as coin. You also have to remove the `hero.say("I should gather coins!")` statement.

1 Like

ok so do i move the "coin = hero.findNearestItem into the loop?

2 Likes

this is what it looks like

1 Like

Yes, do that and add an if loop checking for a coin.

``````if coin:
#move to the coin's position
``````
1 Like

Try doing `hero.move(coin.pos)`

2 Likes

@logan_jordan’s boots do not allow him to do that.

1 Like

ok i will do that right away

1 Like

Just buy boots that do they aren’t expensive.

1 Like

No, he gets those in mountains.

1 Like

i completed the level thanks guys

2 Likes

Great but who’s post helped you solve the problem

1 Like

Use move since it goes to the nearest coin that is sees now instead of the one that was from 1sec ago. This is very important in the mountains.

1 Like

Milton, hes not in mountains yet hes not suppose to use move in the desert yet.

1 Like

It is a good skill and i learned it in the Forest. But the more you know the better

1 Like

also i have been using move since the forest

1 Like

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