Reputation: 11
vscode IDE show me an error on using { print(i,end=' ') } with python language
I have used pycharm IDE and it works correctly ...
def showDivisor(number):
for i in range(1, number+1):
if number % i == 0:
print(i, end=' ')
showDivisor(24)
Upvotes: 0
Views: 1070
Reputation: 16070
You are executing your code via the Code Runner extension, not the Python extension, and so the selected interpreter for the latter is not informing the former. Either use the Python extension to run your code via Run Python File in Terminal
or you need to configure the Code Runner extension to use Python 3.
Upvotes: 1
Reputation: 28753
Running your code in Python 3.6.5 => no problems.
Running with Python 2.7.13 => the given syntax error.
Click in the lower left in the status line on the Python word and select Python 3.x
You can check which python interpreter is used by looking in the settings of the workspace.
Upvotes: 1