import random # checks for an integer between high and low def int_checker(question, low, high): while True: error = f"Please enter an integer that is between {low} and {high}." to_check = input(question) try: response = int(to_check) # checks that the number is equal or more if low <= response <= high: return response else: print(error) except ValueError: print(error) first_number = random.randint(1, 20) second_number = random.randint(1, 20) # Initialise game variables answers_correct = 0 answers_incorrect = 0 # Asks multiplication question user_answer = int_checker(f"Question: {first_number} x {second_number} = ", 1, 400) print(f"You chose, {user_answer}") # Identifies the correct answer correct_answer = first_number * second_number # Display if answer is correct / incorrect and add results to game history if user_answer == correct_answer: answers_correct += 1 feedback ="✅✅✅ Congratulations, that is the correct answer ✅✅✅" else: answers_incorrect += 1 feedback = (f"❌❌❌ Sorry, that was an incorrect answer ❌❌❌. " f"\033[1mThe correct answer is {correct_answer} \033[0m") print(feedback)