byStarTW says to YSITD
import time, random while True: option = random.choice(["question", "game"]) if option == ("question"): a1 = random.randint(1,999) a2 = random.randint(1,999) print ("Q: " + str(a1) + "+" + str(a2) + "=?") ans = input("A: ") if not ans == str(a1 + a2): print("No.") if option == ("game"): npf = str(random.randint(1000,9999)) npf = npf[2:4] print ('Number is ' + npf) exit()