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'。改變一個到另一個。 –