[SOLVED]I need help on Usual Day in codecombat

plz help i need help real bad

:frowning: help me plz

:frowning: :frowning: :frowning: :frowning: :frowning:

please post your formatted code and tell us the problem

# Defeat munchkins, collect coins. Everything as usual.
# Use AND to check existence and type in one statement.

while True:
    enemy = hero.findNearestEnemy()
    # With AND, the type is only checked if enemy exists.
    if enemy and enemy.type == "munchkin":
    # Find the nearest item.
    item = hero.findNearestItem()
    # Collect item if it exists and its type is "coin".
    if item.x:
        hero.moveXY(item.pos.x, item.pos.y)

could you also post a link to the level then I can help you

1 Like

what level is this???

CodeCombat - Coding games to learn Python and JavaScript?

so change the
item .x to if (item and item.type=="coin")

correct me if I am wrong but why do you need commandable methods?

do i add the ( ) ???

change that to if item and item.type == “coin”:

delete this don’t know why you have it

yeah you cant command anything yet…

1 Like

just change the item.x to

if (item and item.type=="coin")

To add on to that you don’t need parenthesis

yeah basically what @Eric_Tang said

You have to check if the item exists and if the item type is “coin”

And delete this


if these posts work please mark it as solved so that we can close the topic

i forgot how do i check if it exists

do if item
20 characters