Python indentation mystery

后端 未结 3 2039
别跟我提以往
别跟我提以往 2021-01-27 00:47

Why am I getting the following error? The last print statement should not be a part of the while loop.

>>> while n>= 0:
.         


        
3条回答
  •  死守一世寂寞
    2021-01-27 01:32

    You need to press enter after your while loop to exit from the loop

    >>> n = 3
    >>> while n>=0:
    ...     n = n-1
    ...     print (n)
    ...                         # Press enter here
    2
    1
    0
    -1
    >>> print ("To A!!")
    To A!!
    

    Note:- ... implies that you are still in the while block

提交回复
热议问题