Syntax Error
Quick summary
Your code has a structural problem — a missing bracket, quote, or punctuation that makes it impossible to parse.
Why this happens
Missing closing bracket, parenthesis, or quote
Incorrect punctuation (e.g., using
;instead of,)Mismatched indentation in Python or other whitespace-sensitive languages
Forgotten colon after
if,for, ordefin Python
Minimal example
print("Hello Worldprint("Hello World")The string is missing a closing quote and the parenthesis is never closed.
How to diagnose
Read the error message — it usually points to the line and column
Check the line mentioned AND the line before it (errors often cascade)
Look for missing brackets, quotes, or semicolons near the reported location
How to fix
Add the missing bracket, quote, or punctuation
Use your editor's bracket matching feature to find unmatched pairs
Run a linter or formatter to catch syntax issues automatically
How to prevent
Use a code editor with syntax highlighting and bracket matching
Enable linters (ESLint, flake8, etc.) to catch errors as you type
Related Resources
Related Lessons
- Errors
Learn about common programming errors
- Debugging Basics
Learn how to debug code systematically
Related Practice
- Spot the Function Syntax Error
Practice finding syntax errors in functions.