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) 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("Wooho! correct answer") else: print("Incorrect!")