skip to Main Content

I am quite new to VS code and I am trying very simple tasks in Python in without great success.

So far I installed Python 3.12.1 on my Mac and also downloaded the plugins "Code runner", "Python" and "Pylance" within VS code (I did everything on the same day). I am just following the instructions of a Udemy corse.

However, while typing the simple following commands, the output of VS code is a bit weird to me and different as I write the same in my terminal:

The output of the basic print() function

Moreover, while changing the parameter sep= from default to something else (like sep = "--"), VS code gives me an error, while the same command works just fine in the terminal.

The error I am facing

I suspect there is something wrong in VS code but I can’t figure out what.

PS: the version of Python running in VS code matches that of what it should be (3.12.1)

2

Answers


  1. So, like others mentioned it is the problem with the version, although u did mention u r using python 3.x, It is running fine in my vs code and IDLE. When I tried to run in an online 2.x interpreter it matched the error.

    Things u can check are:

    • python version command in vs code terminal
    • see if you have 2.x installed too, maybe u haven’t set the path to 3.x version u downloaded.

    All the best!

    Login or Signup to reply.
  2. Please use the official extension Python executing script.

    enter image description here

    https://code.visualstudio.com/docs/python/python-tutorial

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search