[docs] Error in The Python Tutorial

Dhaval Patel dh.electro at gmail.com
Mon Mar 28 01:15:52 CEST 2011


Hi

I am learning Python. As a part of my learning process, I found your
tutorial very helpful.

Today I have found error in section
4.4. break<https://mail.google.com/mail/html/compose/reference/simple_stmts.html#break>and
continue<https://mail.google.com/mail/html/compose/reference/simple_stmts.html#continue>Statements,
and
else<https://mail.google.com/mail/html/compose/reference/compound_stmts.html#else>Clauses
on Loops

>>> 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'...2 is a prime number3 is a prime number4 equals 2 * 25 is a prime number6 equals 2 * 37 is a prime number8 equals 2 * 49 equals 3 * 3


The first output
2 is a prime number is not coming out

I think when it goes in first inner for loop for x in range(2,2):
range (2,2) is []
so it is not printing
2 is a prime number is not coming out

I just want to make sure it my understanding is correct or there is mistake
in document.

Thanks

-- 
Dhaval Patel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20110328/4c398c88/attachment-0001.html>


More information about the docs mailing list