When I try to run my code in REPL, it indents every line automatically. I don’t know what causes it to indent every line. I have showed an example below. As you can see my code is right, but indention makes it fail.
I have reinstalled VS Code and Python many times, but there is no fix.
2
Answers
Indent is necessary in python, its not js or cpp that you define the code that will be executed if the condition is true in {}, here indented code is just like code in curly brackets in other languages. If you want to write something out of the condition, just press the backspace.
NOTE: vscode automatically indent after you write loop of conditional statement etc.
See here
When you copied the Python code, the characters are inserted where the cursor is.
The REPL indents automatically for human typists to save them typing spaces. And then the copied code inserts the additional spaces.
The solution is to avoid this way of to run your code. Instead, save the file and run that.