python: SyntaxError: EOL while scanning string literal

This error message is indicating that there is a problem with a string in your code. Specifically, it is saying that the end of the line (EOL) was reached while the interpreter was still scanning the string, meaning that the string was not properly closed.

A common cause of this error is that the string is not properly enclosed in quotation marks. For example, the following code would produce the "EOL while scanning string literal" error:

my_string = "This is a string
print(my_string)

Watch a course Python - The Practical Guide

To fix this, you would need to add the closing quotation mark to properly end the string:

my_string = "This is a string"
print(my_string)

Another cause of this error is if you use single quotes instead of double quotes or vice versa.

my_string = 'This is a string
print(my_string)

To fix this, you would need to change to double quotes or vice versa:

my_string = "This is a string"
print(my_string)

Another cause could be, you have unescaped special characters like new line, tab, etc.

my_string = "This is a string\n"

Hope it helps!