[docs] Reporting Bugs on The Python Tutorial by version 3.3.2

Harjol Goo harjolgoo at gmail.com
Fri May 24 11:30:10 CEST 2013


Hi,

When I red the Python Tutorial on this website
http://docs.python.org/3/tutorial/controlflow.html
I found a example in
4.4. break <http://docs.python.org/3/reference/simple_stmts.html#break> and
continue <http://docs.python.org/3/reference/simple_stmts.html#continue>
Statements,
and else <http://docs.python.org/3/reference/compound_stmts.html#else> Clauses
on Loops
worked out a different output on my local IDLE

The example is :

>>> 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')

and the first output you gave is :

2 is a prime number

How come? when n is 2, then range(2,n) becomes range(2,2), it has none
element, thus '2 is a prime number' cannot be print out.

On my local IDLE, the output is:

3 is a prime number
4 equals 2 * 2
5 is a prime number
5 is a prime number
5 is a prime number
6 equals 2 * 3
7 is a prime number
7 is a prime number
7 is a prime number
7 is a prime number
7 is a prime number
8 equals 2 * 4
9 is a prime number
9 equals 3 * 3

Seems that break does not work too.

Best Regards,
Harjol Goo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20130524/11ff0823/attachment-0001.html>


More information about the docs mailing list