I’m not sure why, but the coding i have is saying that item is undefined in line 12. Can anyone plz help?
What level? Can you post your code? A screen shot? There are many line 12’s throughout Code Combat.
my bad Usual Day is the level im stuck on
Can you post your code? Either use the </> button or a screen shot would be great. Then we can see line 12 and identify the problem. It’s really difficult to assist with a code problem when I have no idea what your code is. Thanks.
while True:
enemy = hero.findNearestEnemy()
# With AND, the type is only checked if enemy exists.
if enemy and enemy.type == “munchkin”:
hero.attack(enemy)
# Find the nearest item.
items = hero.findNearestItem()
# Collect item if it exists and its type is “coin”.
if item and item.type == “coin”: (reference error: item is not defined)
hero.moveXY(item.pos.x-1, item.pos.y-1)
The error is correct. You have not defined item. You have defined items.
ok so what am I supposed to do cause i looked up some help and it told me to do exactly that.
ok nevermind thanks for the help!!!
so I’m getting an item is not defined error
never mind i fixed it