If the user does not select 1 or 2, I want the code to say "Please enter 1 or 2 to continue", that part works. However if user inputs "6" it asks "Please enter 1 or 2 to continue" as it should but if a valid input is entered directly after an invalid input, code does not display correctly.
I've tried to do this without the requirement function but nothing seems to work how I want it to.
def requirement():
choice = ""
while choice != "1" and choice != "2":
choice = input ("Please enter 1 or 2 to continue.\n")
if choice == "1" and choice == "2":
return choice
def intro():
print ("Enter 1 to enter the cave\n")
print ("Enter 2 to explore the river\n")
play_again = input ("What would you like to do?\n")
if play_again in "1":
print ("You win!")
elif play_again in "2":
print ("YOU LOSE")
print ("Thanks for playing!")
exit()
else:
requirement()
intro()