Skip to content

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, or def in Python

Minimal example

✗ Broken code
print("Hello World
✓ Fixed code
print("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 Glossary

Related Lessons

Related Practice

← Back to language