Now I will type the input 2 and It comes up as wrong

print("What is 1 + 1")
answer = input()
if answer == 2:  
  print("Correct")
elif answer == != 2:
  print("Wrong")

The reason is because input returns a string. A string is text surrounded by quotes "". However, you’re checking if it’s equal to 2, which is an integer, not a string. So instead of that, you have to cast answer to an integer like so:

answer = int(input())

Instead of this, you should just use

else:
4 Likes

I want to supplement @QwertyQwerty88 answer that instead of converting the variable answer to the data type number, you can check this variable for the equality of "2":

if answer == "2":
1 Like