def input_params():
user_input = int(input("Input a number"))
while user_input != 1 or user_input != 2:
try:
user_input = int(input("Input a number"))
if user_input == 1 or user_input == 2:
return user_input
else:
print("Invalid Input")
input_params()
except ValueError:
input_params()
When entering an invalid input such as "adf", and then proceeding to enter a valid input such as 2, the program doesn't process the valid input and asks me to input a value again. The program only comes to process the valid input on the second time I input it.