本文介绍了Python缩进之谜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么会出现以下错误?最后一个print语句不应成为while循环的一部分.
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推荐答案
在while循环后,您需要按 enter 退出循环
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!!注意:-...表示您仍在while块中
Note:- ... implies that you are still in the while block
更多推荐
Python缩进之谜
发布评论