FAQ Zone — Got questions? We got receipts ✦

= vs == in Python: What's the Difference?

This is one of the most common beginner confusions in Python! Don't worry — by the end of this page, you'll never mix these two up again.

Key Difference

Operator Name Function Example
= Assignment Gives a value to a variable x = 10 → x becomes 10
== Comparison Checks if two values are equal x == 10 → True if x is 10

= (Assignment Operator)

The = symbol is used to assign a value to a variable. You're basically saying, "Hey Python, store this under that name."

Python
x = 7
name = "Kiddo"
is_active = True

Think of it like labeling a jar — the jar is the variable and the content is the value.

== (Equality Operator)

The == operator is for comparison. It checks if two values are equal and gives you a True or False result.

Python
x = 7

print(x == 7)  # True
print(x == 5)  # False

Think of it like: "Are these two things actually the same?"

Common Mistakes

Example: Let's Make It Real

Python
age = 18

if age == 18:
    print("You're officially an adult!")

Why this works? Because we're comparing the variable age with the number 18. If they match, the message is printed!

Also Meet: != (Not Equal To)

While we're at it, here's a sibling operator! != checks if two values are not equal.

Python
score = 45

if score != 100:
    print("Not perfect yet!")

Quick Breakdown

When to Use What?

Hope this cleared your doubt! More coming soon — keep learning with Kiddo 🎉