while True:
enemy = hero.findNearestEnemy()
if enemy and enemy.type == "munchkin":
hero.attack(enemy)
item = hero.findNearestItem()
if item and item.type == "coin":
x=item.pos
y=item.pos
hero.moveXY(item.pos.x, item.pos.y)
while True:
enemy = hero.findNearestEnemy()
if enemy and enemy.type == "munchkin":
hero.attack(enemy)
item = hero.findNearestItem()
if item and item.type == "coin":
x=item.pos
y=item.pos
hero.moveXY(item.pos.x, item.pos.y)
This code is correct, just put out lines defining “x” and “y”.