Module 3 · Making decisions in Python · Lesson 2 of 7
Comparison operators
Python gives you six operators for comparing values. Each one asks a question about two values and answers with a True or a False.
⚠ Don't confuse them: == asks “are these equal?”, while a single = assigns a value. Mixing them up is a classic bug.
Most read exactly as they look. The two to watch are == (“equal to”, a double equals) and != (“not equal to”). The double equals matters: a single = is the assignment you already know — it stores a value — whereas == compares two. Reach for the wrong one and your condition won't mean what you think.
They aren't just for numbers — you can compare strings too, and even the results of other expressions. Whatever you compare, the answer is always a boolean, which is exactly what we'll start putting to work.