Help with usual day... lots of help pz

i need help. what is wrong with my code?

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

Please don’t post on different topics.

excuse me i dont understand

oh sorry now i understand but in the other topic it was about enemy.types so i thought that someone could help me there

If it is on the same level there is no need to make another topic for the same level. @Chaboi_3000 @Deadpool198 Can you please close this?

sorry i didn’t know :unamused: i did find the answer though. thanks eric tang

Your good man. No need to feel sad. I did that to I think tbh.

the if enemy.type == ‘munchkin’ suppose to be if enemy and enemy.type == ‘munchkin’:
because the comment line says with and. same with the item

And also add if enemy

And if item

Or else if there’s no enemy or item, it will be an error.

thanks a lot i will see if working now