This article was born some years ago but until lately I found the serious mistake in it. Now I fix it and I’m sure you can make it after you follow the steps. Sorry for those who searched this passage but left with depression.
First of all, you need to run the python code correctly in your Visual Studio Code, just having an annoying problem that you cannot deal with the input() error.
How do you know that? You can install an extension from VS Code Store named code runner(by Jun Han), and you will get a new right-click menu named Run Code in VS Code so that you can run the code in the integrated terminal of VS Code.
If you cannot run the python code in Visual Studio Code totally, this article may be not useful to help you with. You should check your environment, such as reinstall Python or VS Code.
Code runner is a very nice debug tool but it is read-only in the terminal so that you cannot deal with input().
To solve the problem is very easy:
- Install an extension named Python(by Microsoft) and you will get a new right-click menu in your editor.
- Keep on the editor’s UI and just save the .py file into your disk.
- Right click the editor’s UI and click the menu Run Python File in Terminal.
- Now you can get the Terminal on the bottom of the Visual Studio Code and you can input anything you want.
- Enjoy it!
Well, this solution is made for debugging in the integrated terminal. If you would like to save the file and run it in CMD or Powershell, that’s fine.
There are two kinds of terminal window in VS Code. One is called Output and the other is called Terminal. They are very different!
If you are using the extension named Code Runner, you will only open the Output window. The output window is read-only so that you cannot do any inputting, like inputting a string or an integer.
But the Terminal will support inputting anything because it is the same as Powershell(on Windows OS). It is more like a shadow of Powershell, integrating Powershell into the VS Code.
Hopefully you have understood it. Thanks for reading!