Python print statement “Syntax Error: invalid syntax”

Python print statement “Syntax Error: invalid syntax”

In my case I use cmd and execute "python" command, then cmd start to execute input as python code

and if I enter python code like this:

>>> arr = []
>>> while arr.count("1") < 2:
...     arr.append("1")
... print(arr)
  File "<stdin>", line 3
    print(arr)
        ^
SyntaxError: invalid syntax

it'll show SyntaxError: invalid syntax ,

but if I press Enter after "arr.append("1")"  , let the while block be executed first,  then execute "print(arr)"

it'll execute correctly:

>>> arr = []
>>> while arr.count("1") < 2:
...     arr.append("1")
...
>>> print(arr)
['1', '1']
>>>