Loading section...
Assignment vs. Equality
After this, score is 101. This would be nonsense in math (100 = 101?), but in programming it makes perfect sense: "Take the current value of score, add 1, store the result back in score." So How Do I Check Equality? Assignment stores a value: The first returns True ("Is x equal to 5?" Yes!). The second returns False. Using the correct operator in conditions: Confusing = with == is one of the most common beginner bugs. In Python, assignment always flows right to left: the value on the right is stored into the variable on the left. Every time you write a condition in an if-statement or while-loop, you need == to compare. Every time you store a value, you need =. With practice, this distinction becomes automatic.