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 closedAs printed by Python 3.12. Other versions may word it slightly differently.
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
- Count the opening and closing brackets on the highlighted line.
- For long expressions, put each part on its own line and check the parts one at a time.
- The message names the bracket:
(,[or{.