skip to Main Content

How do I configure Visual Studio Code
VScode keeps giving same output from my first line of code

I create new Python file hello.py
I type the following code

print("hello")

the output is

hello

but when I type another code

print("Hello World!")

the output is still the same

hello

enter image description here

3

Answers


  1. According to the image you provided, you didnt save the changes you made to file. You can see that with that white circle on top of the file name. So just save the changes with CTRL + S and everything should be fine

    Login or Signup to reply.
  2. As Hamidou mentioned in another answer, the problem is because you did not save the file. If you want to save the file whenever you make changes, you can turn on the auto save function by clicking auto save under File> auto save

    Login or Signup to reply.
  3. Obviously you didn’t save the file after modifying it, and the white dot next to the file name indicates this information.

    enter image description here

    Press Ctrl+S to save the file, then execute the script.
    Or add the following setting to enable autosave.

        "files.autoSave": "afterDelay",
    

    Also you are using Code Runner to execute code, which is not recommended. If you still want to use it, the following setting save the script before running the code (only for Code Runner).

        "code-runner.saveFileBeforeRun": true,
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search