SyntaxError

noun

say it: “SIN-taks AIR-er” /ˈsɪntæks ˈɛrər/

The error Python reports when it can't read the code, such as a missing quote, colon or bracket; nothing in the file runs until it's fixed.

What is a SyntaxError?

A SyntaxError means Python can't read the code: a quote, bracket or colon is missing, or a word is out of place. Python reads the whole file before running it, so not even the first line runs until it's fixed.

print("Welcome to the bakery)
# SyntaxError: unterminated string literal (detected at line 1)

In a sentence

  • “The SyntaxError message pointed to the line where the closing quote belonged.”
  • “A missing colon after the if gave a SyntaxError before the menu printed anything.”

Level: Novice · More Python terms at this level

Updated