Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Usual Day error python

while True:
    enemy = hero.findNearestEnemy()
    if enemy and enemy.type == "munchkin":
        hero.attack(enemy)
    item = hero.findNearestItem()
    if "Gold Coin":
        hero.moveXY(itemx = itemx.pos.x, itemy = itemy.pos.x)


last line is the error how do I fix it? :frowning_face_with_open_mouth:

That is one weird code… :flushed:
First of all, you have to read the comments more carefully. It explicitly tells you the item.type must be coin, not Gold Coin. Second, you aren’t comparing anything, or checking if there’s really an item available to collect. Third, why are you defining a variable inside a function argument? Just do hero.moveXY(item.pos.x, item.pos.y)

2 Likes

I honestly didn’t know. :sweat_smile: I think reading might help. :slightly_smiling_face:

1 Like

sorry about that:slightly_smiling_face:20charicters

1 Like

I’m 12 btw .lol 20 characters

1 Like

dude dont give out personal info online

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.