Documentation

Type defined in library builtins

SyntaxError

Python raises a syntax error when it encounters source code that cannot be be parsed following the rules of the Python grammar.

Note that the text of the error message depends on the implementation. Different versions of Python and different checking tools will give slightly different messages.

Code
print(2 x)
error
SyntaxError: invalid syntax. Perhaps you forgot a comma?
Code
print(x + 1) * 2)
error
SyntaxError: unmatched ')'
Code
print("Hello World!)
error
SyntaxError: unterminated string literal
Code
from pytamaro import rectangle,
error
SyntaxError: trailing comma not allowed without surrounding parentheses

Logo of PyTamaro

PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI

Privacy PolicyPlatform Version a9143b0 (Sun, 14 Dec 2025 12:09:46 GMT)