Why can’t we write (variable) = (string) in if statement? [duplicate]

  python, string, variables

My code is:

answer = input("choose : y or n")
if answer = "y" :

and it said it had a SyntaxError.
Why can’t we write like this and how can we write instead?

Source: Python Questions

LEAVE A COMMENT