Write Python. Understand every error.

Open the editor

Error guide · SyntaxError

SyntaxError: unterminated string literal

A piece of text was opened with a quote but never closed on the same line.

Example

print("Hello)

What Python says

SyntaxError: unterminated string literal (detected at line 1)

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

Try this code in Py-CRAFT

Why it happens

Text in quotes must start and end with the same kind of quote on one line. Python read "Hello) and never found the closing quote, so it stops before running anything. Using a quote inside text, as in 'It's', also ends the text early.

How to fix it

print("Hello")

Output: Hello

Tips

Learn the ideas behind it

Other common errors

Share this page: