python: SyntaxError: EOL while scanning string literal


Question

I have the above-mentioned error in s1="some very long string............"

Does anyone know what I am doing wrong?

1
131
4/7/2019 3:24:29 AM

Accepted Answer

You are not putting a " before the end of the line.

Use """ if you want to do this:

""" a very long string ...... 
....that can span multiple lines
"""
179
10/18/2017 11:17:52 AM

I had this problem - I eventually worked out that the reason was that I'd included \ characters in the string. If you have any of these, "escape" them with \\ and it should work fine.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon