# Check that users have entered a valid # option based on a list def string_checker(question, valid_ans=("yes", "no")): while True: error = f"Enter a valid option from {valid_ans}" user_response = input(question).lower() for item in valid_ans: # check if the user response ia a word in the test if item == user_response: return item elif user_response == item[0]: return item print(error) print() # Main routine rps_list = ["rock", "paper", "scissors", "xxx"] want_instructions = string_checker("Do you want to see the instructions? ") print(f"You chose: {want_instructions}") user_options = string_checker("Enter your choice: ", rps_list) print(f"You chose: {user_options}") print("The program has ended")