-6
的,而當VAR [5]從「轉變」,「左」或「右」的Python而當變量改變
#Variable Input
name = input("Enter your name: ")
place = input("Enter where you live: ")
sex = input("Are you a boy (Y/N): ")
scaryanimal = input("Enter the type of animal that you are most scared of: ")
happyanimal = input("Enter your favourite type of animal: ")
var=[name,place,sex,scaryanimal,happyanimal,""]
#Main story
#Other code goes here
#Offending While loop
while var[5].lower() != "left" or var[5].lower() != "right":
var[5] = input("Did he go left or right: ")
print(var[5])
我沒有看到你改變'變種[5] '。如果你認爲'vari = input(...)'改變了'var'的內容,你可能會誤解列表分配的語法。 – Kevin
糟糕,只是意識到我忘記用var [5]替換vari,我將var [5]更改爲變量以檢查它是否是錯誤的數組。 :-( –
是你的原始代碼「正確」與'var [5]'而不是'vari'? – tglaria