# Check that users have entered a valid # option based on a list def string_checker(question, valid_ans=('yes', 'no')): error = f"please enter a valid option from following list: {valid_ans}" while True: user_response = input(question).lower() for item in valid_ans: if item == user_response: return item elif user_response == item[0]: return item # print error if user does not enter something that valid print(error) print() # Displays instructions def instruction(): print(''' ****Instructions**** You will see simple math questions like: > 2 x 5 = ? Type your answer in the space provided. Example: > If the question is 2 x 5 = ?, the correct answer is 10. If you answer correctly, you move on to the next question. ✔ Correct: 2 x 5 = 10 → Great job! If you answer incorrectly, don’t worry! ✘ Wrong: 2 x 5 = 12 → That’s not right. The correct answer will be shown so you can learn. Try to get as many correct as you can! Good Luck! ''') # Main routine print("🧠📝💡Multiplication Quiz🧠📝💡") print() # ask user if they want to see the instructions and display them if requested want_instructions = string_checker("Do you want to read the instructions? ") # checks users enter yes (y) or no (n) if want_instructions == "yes": instruction() print("program continues")