0

It’s a very simple program which get user input and print it out in an infinite while loop, like this:

while True:
    s = input('Enter something: ')
    print(s)

But I got the following output when I typed “Hello world”:

Enter something: Hello world
Traceback (most recent call last):
  File "/Users/chuyizhang/Documents/python/break.py", line 2, in <module>
    s = input('Enter something: ')
  File "<string>", line 1
    Hello world
              ^
  SyntaxError: unexpected EOF while parsing

Or it could be:

Enter something: Hello
Traceback (most recent call last):
  File "/Users/chuyizhang/Documents/python/break.py", line 2, in <module>
    s = input('Enter something: ')
  File "<string>", line 1, in <module>
NameError: name 'Hello' is not defined  

when I type “Hello”

And when I input three words or more I will get:

Enter something: Hello world hello world
Traceback (most recent call last):
  File "/Users/chuyizhang/Documents/python/break.py", line 2, in <module>
    s = input('Enter something: ')
  File "<string>", line 1
    Hello world hello world
              ^
SyntaxError: invalid syntax 

So how can I fix it? Does it means that something is wrong with code-runner extension or vscode configuration?

Gama11
  • 31,714
  • 9
  • 78
  • 100

1 Answers1

0

The problem you face for SyntaxError: unexpected EOF while parsing. It may cause for many a reasons like version conflict, indentation, syntaxt error etc.

Your answer may be here

mhhabib
  • 2,975
  • 1
  • 15
  • 29