Invalid Syntax error when running python from inside Visual Studio Code

Looks like this is a bug in VS Code.

When i create a new file, assign python language to it and then save it then it works when i run the python file from within the editor.

But when i create a new file, assign python langauge but dont save it, execute "Run Selection/Line in Python Terminal" afterwards save it and then run "Run Python file in Terminal" it doen't work. So this seems to be an VS Code related issue.


The problem for me was that I accidentally used Shift + Return which executed the python program, when in fact I meant to hit CTRL + Return to move to the next line without touching the mouse.

Using exit() command in the console worked.


Think this is a bug of VS Code.

When you use "run selection/line in python terminal" command, VS Code starts python interpreter and doesn`t quit it after completion.

You should use exit() command in python interpreter window to end python session.

After that "run python file in terminal" will work fine.