I am writing a simple code to generate two random numbers from 1 to 10 and then the user would have to answer it. However, when I am comparing the correct answer of the question to the number user has inputted, they appear to be unequal. I printed the variable and it was exactly the same as what I had input. I am quite new to python and just wanted to make a little code to get familiar.
Code and output is listed below
Code:
answer = 0
num1 = random.randint(0,9)
num2 = random.randint(0,9)
result = num1 + num2
print(result)
print(num1, "+", num2)
answer = input("Answer: ")
if result == answer:
print("Correct")
else:
print("Incorrect")
input("Press ENTER to exit")
Output:
5
4 + 1
Answer: 5
Incorrect
Press ENTER to exit