我正嘗試在Python中創建一個簡單的冒險遊戲。我來到一個地步,我要問用戶是否希望選擇選項A或B和正在使用while循環,試圖做到這一點:Python冒險遊戲 - >在一個while循環中選擇A或B不工作!
AB = input("A or B?")
while AB != "A" or "a" or "B" or "b":
input("Choose either A or B")
if AB == "A" or "a":
print("A")
elif AB == "B" or "b":
print("B")
的一點是,不管你是什麼輸入,問題「選擇A或B」出現。我究竟做錯了什麼?
您可以在代碼中修復縮進嗎?現在,這只是無效的代碼。 – 2011-03-10 19:35:08