import random def int_check(question, low_number, high_number): while True: error = "Choose between {low_number} and {high_number}" to_check = input(question) try: response = int(to_check) # checks that the number is more than / equal to 1 if response >= 2 and response <= 15: print(error) else: return response except ValueError: print(error) # Generate two random numbers num1 = random.randint(1, 20) num2 = random.randint(1, 20) # Ask the question print("=== Math Quiz ===") num_rounds = int_check("How many rounds would you like between 2 to 15? ",2,15) # Game loop starts here while rounds_played < num_rounds: # Rounds headings (based on mode) if mode == "infinite": rounds_heading = f"\n♾♾♾ Round {rounds_played + 1} ♾♾♾" else: rounds_heading = f"\n💿💿💿 Round {rounds_played + 1} of {num_rounds} 💿💿💿" print(rounds_heading) print() answer = int(input(f"What is {num1} + {num2}? ")) # Check the answer correct = num1 + num2 if answer == correct: print("✅ Correct! Well done.") else: print(f"❌ Incorrect. The correct answer is {correct}.")