我有一個輸入,用戶只能做出三種可能的選擇,而我目前正在嘗試調試它,但現在沒有運氣。我試着用數字值的方式嘗試,但它沒有奏效,現在不會讓我輸入任何內容。我也嘗試看看我是否可以對變量(值)執行user_choice!=,但是我的輸出和以前一樣。在Python中僅用3個答案來調試選擇
while loser != 'Lose':
key_error = True
while key_error:
try:
user_choice = str(input('Enter your choice: '))
user_choice = (user_choice.lower())
if user_choice != 'r' or user_choice != 'p' or user_choice != 's':
print(" Please enter either r, s or p")
else:
key_error = False
except ValueError:
print(" Invalid input, Please enter either r, s or p: ")
非常感謝。 –
是的,我明白你的意思。我不知道不在功能,謝謝你教給我。 –