[Solved] Python simple loop EOL while scanning string literal [closed]


You forgot to close your double quotes after you opened them, or maybe you put one by accident:

print "(lines)

Here is your edited code:

myfile = open('log.txt', 'r')
count =  0
while 1:
    lines = myfile.readline()
    if not(lines):
        break
    count = count + 1
    print(lines)
myfile.close()

A SyntaxError: EOL while scanning string literal basically means that it was looking for another quote to end the string, but it came to the End Of the Line (hence EOL), and it didn’t find anything.

solved Python simple loop EOL while scanning string literal [closed]