From what you write, I suspect Python's input()
function raised an EOFError
, and I suspect it has something to do with VSC running Python with the -u
option, which tells Python not to buffer the data coming in from standard input. (It would be helpful, by the way, to know what you typed into the Python prompt before your error occurred.)
Anyway, if I was in your place, the next two questions I would ask would be these:
First, what happens when you bypass VSC and run your Python script directly from Python on the Windows cmd
prompt? Does that give you an nexpected EOF
, too?
cd Users\shaon\Desktop\VSC
python -V rem Check the version number while we're here.
python -u last.py
What difference, if any, does it make when you run python
without the -u
option?
Second, what happens when you replace your code with a simple echo loop and run that from VSC? Here is what I mean by "simple echo loop":
while True:
msg = input() # Type your numbers here, or ctrl-c to exit the loop.
print(msg)
If my suspicion is correct, you will find that your code works when you run it directly from Python, fails (with an EOFError) when you run it with the -u
option, and that you will get an EOFError when you run the echo loop from VSC. In that case, you might try persuading VSC to run Python without the -u
option somehow. But let's see what happens.