import random max_num = 50 min_num = 1 error_str = "Please enter a word out of these options: YES, NO, Y, N " error_int = "Please enter an integer that is between 1 and 50 " def string_checker(question, valid_ans=("yes", "no")): while True: # Get user response and make sure it's lowercase user_response = input(question).lower() for item in valid_ans: # check if the user response is a word in the list if item == user_response: return item # check if the user response is the same as # the first letter of an item in the list elif user_response == item[0]: return item # print error if user does not enter something that is valid print(error_str) print() def int_check(question): while True: to_check = input("how many rounds would you like to play? ") try: response = int(to_check) # checks that the number is more than / equal to 1 if min_num <= response <= max_num: print(error_int) else: return response except ValueError: print(error_int) def instruction(): print("""instructions: insert a number next to the equal sign of the question. Questions will look lik this: 5 x 5 = program will ask how many questions you would like, enter the desired amount and press enter """) #main program starts here this is use from quiz.py want_instructions = string_checker("Would you like to see instructions? ") if want_instructions == "yes": instruction() rounds = int_check() print(f"the chosen amount of rounds is {rounds}") rounds_played = 0 score = 0 while rounds >= rounds_played: rounds_played += 1 random_1 = random.randint(2, 15) random_2 = random.randint(2, 15) answer = random_1 * random_2 player_ans = int(input(f"""=================================== {random_1} X {random_2} = """)) if player_ans == answer: score += 1 print("""=================================== Correct""") else: print(f"""=================================== Incorrect, answer was {answer}""")