Syntax Error on good code

suggest change

The vast majority of the time a SyntaxError which points to an uninteresting line means there is an issue on the line before it (in this example, a parenthesis is never closed):

def my_print():
    x = (1 + 1
    print(x)

On Python 3.14 this raises:

File "<input>", line 2
    x = (1 + 1
        ^
SyntaxError: '(' was never closed

The most common reason for this issue is mismatched parentheses/brackets, as the example shows.

There is one major caveat for print statements in Python 3:

Because the print statement was replaced with the print() function, so you want:

The rest of this sentence is missing.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents