验证用户输入,循环永不满足? (Python 3.2.1.1)

时间:2015-05-29 11:59:37

标签: validation loops while-loop user-input infinite-loop

提前感谢任何帮助过的人。

我正在使用此代码来验证我正在编写的程序的用户输入,但用户输入永远不会满足 WHILE 循环,我无法理解原因。

User_Answer = input('Which is the correct answer A,B,C or D?' ).upper()
#Ask user which they believe correct and save it as variable with the identifier User_Answer

while User_Answer != 'A' and User_Answer !='B' and User_Answer !='C' and User_Answer !='D': 
    User_Answer = input('Which is the correct answer A,B,C or D?' ).upper()
# Is user entry valid in the form of A,B,C or D and re-asks question if not. 

else:
    do something

0 个答案:

没有答案