import random def string_checker(question, valid_ans=("yes", "no")): error = f"Please enter a valid option from the following list: {valid_ans}" while True: user_response = input(question).strip().lower() if not user_response: print(error + "\n") continue for item in valid_ans: if user_response == item or user_response == item[0]: return item print(error + "\n") def instruction(): print(""" ~~~ 𝐐𝐮𝐢𝐳 𝐈𝐧𝐬𝐭𝐫𝐮𝐜𝐭𝐢𝐨𝐧𝐬 ~~~ ~~ How to Play: - Select the total number of questions you want to play. - A problem will appear on your screen each turn. Type your numeric answer and hit Enter. - You'll immediately see if your response was right or wrong. - Need to leave early? Type at any prompt to quit the game instantly. Good luck! """) # --- Main Program --- score = 0 answer_check = ["yes", "no"] # Check if user wants instructions want_instruction = string_checker("Do you want to see the instructions? ", answer_check) if want_instruction == "yes": instruction() # Ask for rounds rounds_input = input("\nHow many rounds would you like to play? ").strip().lower() while not rounds_input.isdigit() or int(rounds_input) < 1: print("⚠️ Please enter a valid number greater than 0. ⚠️") rounds_input = input("How many rounds would you like to play? ").strip().lower() total_rounds = int(rounds_input) question_num = 1