← Dictionary
Code·basic

Syntax error

Your code doesn't parse. The grammar is wrong.

A syntax error means your code doesn't parse — the language can't even read it, let alone run it. Common causes:

  • Missing a colon at the end of an if, for, or def line.
  • Unclosed quotes: "hello with no closing quote.
  • Mismatched brackets: [1, 2, 3}.
  • Incorrect indentation in Python.

Syntax errors are the easiest kind of error to fix, once you read the message carefully. Python's error output tells you the file, line number, and often points to the exact character.

When you paste an error into Claude, paste the whole message — the line number and pointer are where most of the information lives.

Related