import random # Inter checker function to validate the user input is a number and is within a number range def int_check(question, low, high): error = f'Please enter a number between {low} and {high}.' while True: try: response = int(input(question)) if response >= low and response <= high: return response else: print(error) except ValueError: print(error) # Variables rounds_played = 0 rounds = int_check(f"How many rounds do you want? (3 to 10): ", 3, 10) print(f"Great you chose {rounds} rounds.") while rounds_played < rounds: num1 = random.randint(1, 10) num2 = random.randint(1, 10) answer = num1 * num2 user_answer = int_check(f"What is {num1} x {num2}? ", 1, 100) if answer == user_answer: print("Woohoo! correct answer") else: print("Incorrect!") rounds_played += 1