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?