我正在尝试从字典中调用函数,但不断收到一条错误消息,指出name: one_1_1 is not defined on line 11
。
我不确定如何解决这个问题,我已经浏览了这个网站,并且认为我已经正确地完成了所有事情,但是当我尝试运行我的程序时,该错误一直在发布。 请帮忙。
def choice():
choice = raw_input(prompt)
choice.lower()
def wall():
print "You ran into a wall."
print "Try again... "
def really():
print "Don't you know how to give directions?"
print "Try again..."
prompt = "> "
n = "north"
s = "south"
e = "east"
w = "west"
loop = True
i = {
#first number represents the row
#second number represents the column
11: one_1_1,
12: one_1_2,
21: one_2_1
}
def one_1_1():
"You are in a dark room"
"Which way do you go?"
left_corner(11)
def one_2_1():
print "I am what you get when"
print "you go south"
def one_1_2():
print "This is what you get when"
print "You go east"
def left_corner(position):
choice()
while loop == True:
if choice == n:
wall()
i[position]()
elif choice == s:
i[position + 10]()
elif choice == e:
i[position + 1]()
elif choice == w:
wall()
i[position]()
else:
really()
one_1_1()