# Defeat munchkins, collect coins. Everything as usual. # Use AND to check existence and type in one statement. while True: enemy = hero.findNearestEnemy() item= hero.findNearestItem() # With AND, the type is only checked if enemy exists. if enemy and enemy.type == "munchkin": hero.attack(enemy); if item and item.type=="coin": pos=item.pos hero.moveXY(pos.x, pos.y) # Collect item if it exists and its type is "coin".
Try to remove the line 11
plus you would need a space
pos = item.pos
It’s stylistic and doesn’t affect on the results.
sorry. I didn’t know. That was what it taught you.
How did you complete it? I’ve tried to do what the others have said and it didnt work.
What did you do?