Reputation:
I am getting this error while running a simple code using Visual Studio Code's CodeRunner extension while print values in the same line separated using a space in python.
for i in range(0,6):
print(i, end = ' ')
Error: print(i, end = ' ') SyntaxError: invalid syntax. However, the same code runs I select 'Run Python File in Terminal' Please help me out on this issue and suggest possible alternatives/fixes.
Upvotes: 0
Views: 827
Reputation: 332
The reason you are getting SyntaxError has to do with your python terminal version being different than the one you've told vscode to use and therefore the one coderunner uses. You can change the vscode python interpreter (version) by using CTRL+SHIFT+P
in vscode. This will bring up the Command Pallet where you can type in python select interpreter
and select the version of python that matches your terminal version.
If you don't know which version of python your terminal version is that is running the code correctly, go to the terminal and type python --version
Upvotes: 1