0
我刚开始学习OOP并且一直在努力。这个问题可能会让我立刻面对。“全局名称未定义”错误
def Travel():
choice = str()
choice = input("Where will you search?\nChoose F for Front or T for Trunk\n")
if choice == "F":
LocF()
elif choice == "T":
LocT(i)
def LocF():
print("Looking through the front of the car, you find a screwdriver.\nYou figure that might help a bit.")
inv = ("screwdriver")
return i
def LocT(i):
if i[0] == "screwdriver":
print("You use your screwdriver to pop the inside of the trunk door lock off.")
time.sleep(0.5)
print("You make it to class with seconds to spare.")
else:
print("You can't get to the trunk yet.")
Travel()
您没有在'LocF()'中定义我... –
,您创建了一个变量'inv',但尝试返回一个不存在的变量'i'。改变一个到另一个。 –