I'm making a simple 'if' statement to check if the answer the user gave to a multiplication sum was correct, and have the code print "correct" or "wrong". However I cant understand why the code keeps returning wrong even when I return the correct answer.
Here is the code.
print("what is 2 x 10")
answer = 2 * 10
user_answer=input("answer: ")
if answer == user_answer:
print("correct")
else:
print("wrong")
print(f"the answer was {answer}")
user_answer = int(input("answer: "))
To fix this bug, you need to convert the user's input to an integer using the int() function before comparing it with answer.