2 Answers

Add this your settings.json

  "debug.terminal.clearBeforeReusing": true

Then run your python file using VS Code Debugger, just hit F5 then it will clear the terminal everytime you run the code. Tell me if it work!

If you are using code-runner, first make sure you have installed the code-runner extension.

Select Run Code when using this extension for the first time:

enter image description here

Check the following in settings so that the last run result can be cleared automatically when running the file:

enter image description here

enter image description here

You can also add the following codes to your settings.json:

"code-runner.clearPreviousOutput": true,

"code-runner.runInTerminal": true

Related