This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author yoshokun
Recipients georg.brandl, yoshokun
Date 2008-08-02.02:54:17
SpamBayes Score 0.0015018159
Marked as misclassified No
Message-id <1217645659.61.0.258873000656.issue3490@psf.upfronthosting.co.za>
In-reply-to
Content
In section 4.4 of the Python Tutorial
(http://docs.python.org/tut/node6.html) there is a code example using
prime numbers that results extraneous output. The else is incorrectly
indented one tab too far to the right and is nested under (for x in
range) rather than (for n in range).

Current:

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

Correct:

>>> 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'
...
History
Date User Action Args
2008-08-02 02:54:19yoshokunsetrecipients: + yoshokun, georg.brandl
2008-08-02 02:54:19yoshokunsetmessageid: <1217645659.61.0.258873000656.issue3490@psf.upfronthosting.co.za>
2008-08-02 02:54:18yoshokunlinkissue3490 messages
2008-08-02 02:54:17yoshokuncreate