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)
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.