When I run the following code, if I input the correct value of 1 or 2 on the first try, it works fine. However, if I input an incorrect value, the code then correctly prompts me to fix it. And when I then put in a correct value, instead of returning 1 or returning 2, it is returning None
. Any reason why? Thanks!
def check_input(input_message, option1, option2):
response = input(input_message + ":\n").lower()
if int(response) == option1:
return 1
elif int(response) == option2:
return 2
else:
print_pause("I'm sorry I don't recognize that response. Try again!", 2)
check_input(input_message, option1, option2)
decision = check_input("Please type 1 to go into the dark cave. 2 to go into the dweilling", 1, 2)