我为我的基于文本的游戏制作了这段代码,我收到一条错误消息
line 1, in <module>
userInput = input("Please enter a direction in which to travel: ")
File "<string>", line 1, in <module>
NameError: name 'north' is not defined
这是我的代码
userInput = input("Please enter a direction in which to travel: ")
Map = {
'north':'that way leads to the kitchen',
'south':'that way leads to the dining room',
'east':'that way leads to the entry',
'west':'that way leads to the living room'
}
if userInput == north:
print Map['north']
elif userInput == south:
print Map['south']
elif userInput == east:
print Map['east']
elif userInput == West:
print Map['west']
elif userInput == '':
print "Please specify a various direction."
else:
quit
谢谢你的帮助