[SOLVED] Usual day


#1

Help please…in Usual Day, they said:

#Find the nearest item.
So I typed:
item = hero.findNearestItem
And then they said:
# Collect item if it exists and its type is “coin”.
I put
_ if item:_
#Move to the position of the item.
pos = item.pos
x = pos.x
y = pos.y
hero.moveXY(x, y)
Is that the right code?


#2

First of all please format your code because we can’t see the structure of the code:
https://discourse.codecombat.com/t/essentials-how-to-post-format-your-code-correctly/15521/5
And please be specific when posting next time. For now, I’ve done the job for you.


#Find the nearest item.

item = hero.findNearestItem

# Collect item if it exists and its type is “coin”.
I put
 if item:
    #Move to the position of the item.
    pos = item.pos
    x = pos.x
    y = pos.y
    hero.moveXY(x, y)

You forgot the while True Loop. Without that, this code will run only once. Try adding While True And see if it works. :wink:


#3

Thank you, @Chaboi_3000! It did work.