I have been writing a Python 3 program that includes a keyboard input and I wanted to test what comes in, to make sure it meets certain criteria, namely it should be a single character and only a, b or c. Being new to Python, I have cobbled together some code from other pages here, and it seems to work, but I'm not sure that it follows best practice (or even is correct programming). So any comments/improvements or alternatives most welcome.
chars = set('abc')
trigger = 0
while (trigger == 0):
answer = input(':')
if len(answer) != 1:
print ('Please enter only one character')
if any ((c in chars) for c in answer):
trigger = 1
else:
print ('please answer a,b or c')