I want to prevent the user from entering an input other than + , - , / , * , and the code I've written works fine and it prevents user from entering numbers, strings, spaces, but when user presses the ENTER KEY the program skips the input question and goes to the next code block.
How can I prevent a user from pressing ENTER KEY and skipping the "Enter an Operator: " input question?
op_error = True
while op_error:
op_error = False
op = input("Enter an Operator: ")
if op in "+-/*":
break
elif len(op.strip()) == 0:
op_error = True
else:
op_error = True