在python教程中有一个例子(复制如下),不else
应该缩进吗?我运行了代码,但它没有工作,但我缩进了它(else
),它工作了。是,我说的对吗?如果文档有误,那么如何将其作为错误报告给 python 文档人员?
>>> for n in range(2, 10):
... for x in range(2, n):
... if n % x == 0:
... print n, 'equals', x, '*', n/x
... break
... else:
... # loop fell through without finding a factor
... print n, 'is a prime number'
...