AssignCompares

This programming language misconception is about the meaning of Python's = operator.

Incorrect and Correct Conception

Convince Yourself

Loading...

You see that the value of a in the second printout is 3. Thus the a = b assigned a value to variable a. It did not just compare a to b.

When the statement a == b executes, the values of a and b are compared, resulting in False. The statement does not do anything with this result, and the second print thus produces the same output as the first print.

Learn More

If you would like to learn more about this misconception, including its possible origins, symptoms students who hold this misconception might exhibit, the related programming language concepts, links to the corresponding parts of the Python language specification, and related misconceptions, check out AssignCompares in the progmiscon.org misconception inventory.


This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.

AssignCompares

Logo of PyTamaro

PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI

Privacy PolicyPlatform Version 1e22f67 (Sat, 19 Jul 2025 12:40:41 GMT)