-1

I wrote this code:

def main():
    num_tokens = []
    str_tokens = []
    user_data = input("Insert Delimited Data: ")
    split_data = user_data.split(sep="|")
    for i in split_data:
        if i.strip().isnumeric():
            num_tokens.append(i)
        else:
            str_tokens.append(i)
    print("String Tokens: {}\nNumeric Tokens: {}.format(len(str_tokens), len(num_tokens)))
    return

And it says EOL while scanning string literal, what does that mean and why?

Aviv Yaniv
  • 6,188
  • 3
  • 7
  • 22
  • Does this answer your question? [python: SyntaxError: EOL while scanning string literal](https://stackoverflow.com/questions/3561691/python-syntaxerror-eol-while-scanning-string-literal) – AMC Aug 28 '20 at 11:05
  • Yes, and that was a big mistake, forgetting to type the " – Robotic Programmer Aug 31 '20 at 07:17

1 Answers1

0

The error you get:

SyntaxError: EOL while scanning string literal

Is a syntax error, because that the last line is malformed.

The closing " of the string format is missing.

Change:

print("String Tokens: {}\nNumeric Tokens: {}.format(len(str_tokens), len(num_tokens)))

To:

print("String Tokens: {}\nNumeric Tokens: {}".format(len(str_tokens), len(num_tokens)))
Aviv Yaniv
  • 6,188
  • 3
  • 7
  • 22
  • https://stackoverflow.com/questions/3561691/python-syntaxerror-eol-while-scanning-string-literal – AMC Sep 01 '20 at 01:04