如何在python中验证输入?

时间:2015-03-05 14:23:56

标签: validation python-3.x input

我有3个选项,我希望用户可以选择(A,B或C)

这是我到目前为止尝试过的代码:

while True:
form = input("Please enter your class:")
if form == ('A', 'B', 'C'):
    print("Please continue.")
    break
else:
    print("Class does not exist, please try again.")

1 个答案:

答案 0 :(得分:0)

更改

if form == ('A', 'B', 'C'):

if form in ('A', 'B', 'C'):