for loop in VS Code / python does not start

Viewed 3280

I am working with Python 3.7 in VS Code.

Since an hour it seems like I cannot start for loops anymore. for example if I try

for i in range(3):
    print(i)

In my Terminal the following shows up:

>>> for i in range(3):
...         print(i)
...

It changes only if i run a different line of code, then it gives me an error message. For me it looks like VS Code is waiting for further input in the loop. for example if I interrupt it with

a = 1

and run that twice, it looks like:

>>> for i in range(3):
...         print(i)
... a = 1
File "<stdin>", line 1
a = 1
^
SyntaxError: invalid syntax
>>> a = 1

when working in jupyter notebook for example, everything works fine, so I guess it has sth to do with VS Code.

1 Answers

Press Enter after the loop is finished. Leave the final line blank and hit enter again. The loop should work fine.

Related