#i want num1 to never be smaller than num2 import random

def problem():
    # Set the possibilities
    nums = ["1","2","3","4","5","6","7","8","9","10","11" ,"12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31"]

    # Set the variables
    op = input("pick an operation (+ ,*,-,/)")
    num1 = random.choice(nums)
    num2 = random.choice(nums)

    # Ensure no duplicates
    def no_same():
        nonlocal num1, num2
        while num1 == num2:
            num1 = random.choice(nums)

    no_same()

    # Print the problem
    print(num1 + " " + op + " " + num2)

    # Find answer
    def def_anser():
        nonlocal num1, num2
        if op == "*":
            print(int(num1)*int(num2))
        elif op == "+":
            print(int(num1)+int(num2))
        elif op == "-":
            # Ensure result is not negative
            while int(num1) < int(num2):
                num1 = random.choice(nums)
                print("New problem: " + num1 + " " + op + " " + num2)
            print(int(num1)-int(num2))
        elif op == "/":
            if int(num2) != 0:
                print(int(num1)/int(num2))
            else:
                print("Error: Division by zero is not allowed.")

    def_anser()

while True:
    user_input = input("Enter 'run' to execute the problem: ")
    if user_input.lower() == 'run':
        problem()
    else:
        print("Exiting program.")
        break