Code with the error

width = 6
height = 4
print((width + height) * 2
print("done")

Error message (Python 3.12, last line)

SyntaxError: '(' was never closed

Corrected code

width = 6
height = 4
print((width + height) * 2)
print("done")

Output

20
done

Common causes

  • One closing bracket is missing after nested calls such as print(len(items).
  • A list or a dictionary written on several lines has no final ] or }.
  • A bracket was deleted while editing the line.
  • The closing bracket is inside quotes, so Python reads it as text.

Practise in the course

Lesson: Math Operations

Frequently asked questions

Why does the message name an earlier line than the one I was editing?

It points at the line where the unclosed bracket was opened. Look from there downwards.

Does the same message exist for square and curly brackets?

Yes: '[' was never closed and '{' was never closed are fixed the same way.