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'を返そうとします。一方を他方に変更します。 –