我編程的蟒蛇疑難解答,我一直在尋找它真的很難鏈路輸入了新的問題:如何將輸入鏈接到Python中的新問題(故障排除程序)?
Question 1
print("Has your car got a flat tyre? 1. Yes 2. No")
choice=input("1/2")
if choice == "1":
goto (Question 2) #How do I link this input
elif choice == "2":
goto (Question 3)
else:
print("Answer not applicable")
Question 2 #Into this question?
print("Have you taken your car to the petrol station? 1. Yes 2. No")
choice=input("1/2")
if choice == "1":
goto (Question 4)
elif choice == "2":
goto (Question 5)
else:
print("Answer not applicable")
Question 3
print("Has your car recently had an MOT? 1. Yes 2. No")
choice=input("1/2")
if choice == "1":
goto (Question 6)
elif choice == "2":
goto (Question 7)
else:
print("Answer not applicable")
我需要知道如何做到這一點之前,我跟我的項目走得更遠。所有的幫助表示讚賞。
你不能這樣做,這是沒有意義的。 Python沒有GOTO,你不能跳轉到某個標記。考慮使用函數來表示問題,然後調用適當的函數。 – jonrsharpe