I made a Python script that generates multiplication problems my only issue is if the multiplication problem is wrong. I need to get the script to display the question again and run through the if statement wouldn't I need to make the if statement a function? If so how would I do that? I'm still pretty new to python any help would be appreciated!
import random 
limit = 12
number_problems = int(input('How many problems do you want to solve? '))
for i in range(number_problems):      
    x, y = random.randint(1,limit), random.randint(1,limit)
    true_ans = x*y
    print(x ,'x', y , '=' )
    ans = int(input('your answer:'))
    if ans == true_ans:
        print("correct!")
    elif ans < true_ans:
        print('Your answer is to low')
        print(x ,'x', y , '=' )
        ans = int(input('your answer:'))
    elif ans > true_ans:
        print('Your answer is to high')
        print(x ,'x', y , '=' )
        ans = int(input('your answer:'))
    else:
        print("incorrect! The answer is ", true_ans)
 
     
    