Reputation: 1
I'm fairly new to python...aka just started. So i was making a simple game and i'm trying to get a dictionary to work through out a claas and cant get it to work.
class Map(object):
def __init__(self):
self.Eng = {
"1": "Map_Eng()",
"2": "Guard_Fight()",
"3": "Item_Eng()"
}
def enter_room(self):
pass
def exit_room(self):
print("You move onto the next room.")
return self.Eng[1]
Upvotes: 0
Views: 26
Reputation: 32319
The problem is small. Your dictionary has an entry with key "1"
(a string), but not with key 1
(a number). To fix your problem, change the line
return self.Eng[1]
to
return self.Eng["1"]
Upvotes: 3