import random correct = 0 incorrect = 0 a, b = random.randint(5, 20), random.randint(5, 20) correct_answer = a * b rounds_played = 0 def integer_check(question, low, high): """checks if users want a best of three or a best of five""" while True: error = f"Now listen here, partner... pick yourself a number between {low} and {high}. Don’t go gettin’ fancy — just stay in range or you’ll hear about it." try: response = int(input(question)) if low <= response <= high: return response else: print(error) except ValueError: print(error) rounds_input = integer_check("Number of questions? Minimum of 1, max of 10 ", 1, 10) a, b = random.randint(5, 20), random.randint(5, 20) correct_answer = a * b while rounds_played < rounds_input: rounds_heading = f"\n*** Round {rounds_played + 1} of {rounds_input} ***" print(rounds_heading) while True: user_answer = input(f"What is {a} x {b}: ") if not user_answer.isdigit(): continue user_answer = int(user_answer) if user_answer == correct_answer: print("Correct!") correct = + 1 elif user_answer != correct_answer: print(f"Incorrect womp womp womp the correct answer is {correct_answer}") incorrect = +1 break