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.
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
- Check that every opening quote has a matching closing quote of the same kind.
- Use double quotes around text that contains an apostrophe:
"It's fine". - In the Py-CRAFT editor, text is coloured green. If the rest of the line turns green too, a quote is missing.