python eol 1

python eol

# If you are facing eol while scanning string literal to resolve add the missing quotes and use the format specifier properly.

# Example of EOL Error
def getName():
    print("My name is Chandler Bing)
getName()

# Output
  File "c:\Projects\Tryouts\listindexerror.py", line 2
    return "My name is Chandler Bing
                                    ^
SyntaxError: EOL while scanning string literal

# Solution to EOL Error
def getName():
    print("My name is Chandler Bing")
getName()

# Output
My name is Chandler Bing

Here is what the above code is Doing:
1. We define a function getName()
2. We print a string inside the function
3. We call the function
4. The function is executed and the string is printed

Similar Posts