Why am I getting the following error? The last print
statement should not be a part of the while
loop.
>>> while n>= 0:
... n = n-1
... print(n)
... print ("TO A!!")
File "<stdin>", line 4
print ("TO A!!")
^
SyntaxError: invalid syntax
You need to press enter after your
while
loop to exit from the loopNote:-
...
implies that you are still in thewhile
blockThe default python shell works OK for typing but it really does not understand pasting from clipboard. The real solution is to install
ipython
, which is an advanced shell for python with many niceties:I guess that the error shows up because python shell don't support that. It want you to do one thing in a time.! I do the same things in my python 2.7 shell and it said:
when I do the same thing in my python 3.4 shell, it said:
unexpected indent.