Jam*_*Lee 2 python indentation visual-studio-code
I'm working on a Python project using VS Code as my editor, and I'm getting a Python indentation error when I place comments in between blocks of code. Specifically:
while score0 < goal and score1 < goal:
if player:
...
else:
...
player = other(player)
# END PROBLEM 5
# BEGIN PROBLEM 6
"*** YOUR CODE HERE ***"
say(score0, score1)
Run Code Online (Sandbox Code Playgroud)
I'm getting an indentation error when I evoke say(score0, score1), but the error gets fixed if I indent the comments to match the surrounding lines. Is this a general rule in Python, or a requirement of using VS Code?
Lines that do not start with a # are considered code.
So your
"*** YOUR CODE HERE ***"
Run Code Online (Sandbox Code Playgroud)
Line is actually code, so Python expects code after it to match it's indent (since the while loop is over), and doesn't know why say is indented, so it throws the Indentation Error
So this is a Python thing, not a VSCode thing