Token error: EOF in multi-line statement

Not a direct answer to the original question, but since online searching brought me here... I got this error for another reason: a stray parenthesis! But it came from flake8. Here's a snippet of code to reproduce it:

import socket


def all_good(name):
    name_line = f"Name: {name}")
    print(name_line)

I saved this into a file called error.py. Now if I run flake8 on it:

$ flake8 error.py 
error.py:1:1: E902 TokenError: EOF in multi-line statement

Which is rather puzzling as there is no multi-line statement anywhere! Eventually I found the bug, but the moral of the story is that I'd have found it much quicker if I had run it through the python interpreter:

$ python3 error.py 
  File "error.py", line 5
    name_line = f"Name: {name}")
                               ^
SyntaxError: unmatched ')'

Fix it:

import socket


def all_good(name):
    name_line = f"Name: {name}"
    print(name_line)

And now flake8 will actually do it's job:

$ flake8 error.py 
error.py:1:1: F401 'socket' imported but unused

It's obvious, but remember: check the code with python3 first, then run it through linters or other checkers.


Your first line in choices variable doesn't have an apostrophe (') at the end.


You're missing the closing quote on the Fortune-Telling line.

That is easy to find because that is where the syntax highlighting becomes different.