Write Python. Understand every error.

Open the editor

Error guide · SyntaxError

SyntaxError: '(' was never closed

An opening bracket has no matching closing bracket.

Example

total = (2 + 3
print(total)

What Python says

SyntaxError: '(' was never closed

As printed by Python 3.12. Other versions may word it slightly differently.

Try this code in Py-CRAFT

Why it happens

Every (, [ and { must be closed in the right order. When one is missing, Python keeps reading the next lines as part of the same expression. The error usually points to the line where the bracket was opened, not to where it should have been closed.

How to fix it

total = (2 + 3)
print(total)

Output: 5

Tips

Learn the ideas behind it

Other common errors

Share this page: