[SOLVED] Usual day

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?

1 Like

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:

2 Likes

Thank you, @Chaboi_3000! It did work.

1 Like

try using hero.cleave(enemy)

1 Like

it isnt work with those code @Chaboi_3000 even with loop

1 Like

Hi @Blob, welcome to the CodeCombat Discourse! :tada:
Do you need help with your code? If so please post it, formatted as instructed in this topic:

What Chaboi suggested would work, you’d need to take out the “I put”. Anyway, write some of your own code and I’ll see what I can do.
Danny

2 Likes

Continuing the discussion from [SOLVED] Usual day:

can some one help me with this one please what do i put for it in python

Please post your code.

1 Like

image

You are missin a )
20 chars

On the last line you haven’t defined targetPos

Where do you want to move.

And is that your full code?