In Python, '=' is to assign a value, like a=5, while '==' in an if statement checks for equality. For example, `if a == 5:` asks, "is a equal to 5?", it does not set a to 5. This difference took me time to grasp, as I kept using one for the other in my early code. You see, after a decade of writing answers in pen for government exams, where we use '=' for both, this shift to a computer's precise logic was a small, but important, sea change.
#exams#study
Jump in to reply β no account needed.