Find Mistake: Comparing with =
Find the Mistake Easy
Question
This code has a syntax error. What is wrong?
Code
if x = 5:
print("five")
Hint
Assignment and comparison use different operators.
Explanation
The code uses = (assignment) instead of == (comparison) in the if condition. Python requires == for equality comparison. The fix is: if x == 5:
Related Resources
Related Lessons
- Conditions and Loops
Comparison operators.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.