I've only started learning to program a few days ago and I chose python as my starting language. I'm in the process of making a basic calculator with 4 operators to choose between. I want to make it so that if you input a character that is not one of these: + - * / then it would not try to calculate, but print 'Invalid operator' instead. The calculator works on 3 human inputs; a (first number), operator, b (second number).
Things I've already tried:
if not operator == '+' or '-' or '*' or '/'
print('Invalid operator')
if not operator == ('+' or '-' or '*' or '/')
print('Invalid operator')
So, only if the first operator is used will it not print 'Invalid operator', no matter the order. If any of the other three show 'Invalid operator' after the answer if printed. An answer on what I've done wrong and how to come about fixing my code would be greatly appreciated. Also an explanation on how things like this work for future reference would be cool too, since I haven't followed any online courses, I've just been using python documentation and stack overflow.