好吧,所以我正在做一個基於文本的冒險,我已經介紹了可變的黃金。我試圖在故事選項之一中選擇黃金。我的語法如下:嵌套如果語句不起作用
if choice == "A":
print("There is no answer. But there is 5 gold on the floor, would you like to pick it up? Type: YES or NO")
yesorno = input()
if yesorno == "YES":
g = g + 5
print("You picked them up.",ge,"g")
elif choice == "B":
print("Someone from a long distance away shouts: 'Shut up",name,"!'. Then the man walks away down what seems like a echoey corridor.")
elif choice == "C":
print("Nothing happens, you are left to die.")
sys.exit("You lost")
選擇「A」工作正常,但如果我想選擇B或CI必須輸入他們的兩倍,因爲它顯示在這裏:
Either type A, B or C to choose.
B
B
Someone from a long distance away shouts: 'Shut up g !'. Then the man walks away down what seems like a echoey corridor.
有啥你的錯誤,並哪來的的choise B碼,讓錯誤 –
你的意思是選擇B時的當T他的結果「B」被放置在yesorno返回一個錯誤? – RyPeck
如果有錯誤提供回溯和代碼的相關部分(它意味着[SSCCE](http://www.sscce.org/)) – zero323