I need users to be able to type x to exit if they get a question wrong.
I've tried changing the input to a string and then if the answer isn't x then convert the string to an integer with int(user_ans) and even making another value and with ans_string == int(user_ans). Is there any way to add a break to the end if they type x?
if level == 1:
solution = number_one + number_two
print("What is", number_one, "plus", number_two)
user_ans = int(input())
if user_ans == solution:
print("Correct")
number_one = random.randrange(1,10)
number_two = random.randrange(1,10)
rounds = rounds + 1
else:
print("Try again")
I expect the program to still function but also be for the user to quit.