Reputation: 21
I keep getting an "unresolved reference" error even though I made a statement to it.
verb_dict = {"say": say, "examine": examine}
The error is after the examine
:
def examine(noun):
if noun in GameObject.objects:
return GameObject.objects[noun].get_desc()
else:
return "There is no {}".format(noun)
Did I do something wrong when coding it?
I am also using pycharm community edition.
Upvotes: 0
Views: 298
Reputation: 1735
I can't replicate your problem in PyCharm 2016.14 I run the following code with no issue:
class GameObject:
class_name = ""
objects = {}
def __init__(self, name):
self.name = name
GameObject.objects[self.class_name] = self
def examine(noun):
if noun in GameObject.objects:
return GameObject.objects[noun].get_desc()
else:
return "There is no {}".format(noun)
print(examine('try'))
Output is
>>> There is no try
Upvotes: 1
Reputation: 21
This is the GameObject class. I don't see a problem in there.If you need more tell me.
class GameObject:
class_name = ""
desc = ""
objects = {}
def __init__(self, name):
self.name = name
GameObject.objects[self.class_name] = self
Upvotes: 0