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.

classification
Title: typo in tutorial section 4.4 - final break statement is missing
Type: Stage:
Components: Documentation Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: Kyte999, georg.brandl, rhettinger
Priority: normal Keywords:

Created on 2008-03-08 00:40 by Kyte999, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg63374 - (view) Author: k-e-n (Kyte999) Date: 2008-03-08 00:40
The code from section 4.4 of the tutorial follows.
This code does not produce the output shown.
Adding a final break statement will fix this.

>>> 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 number
3 is a prime number
4 equals 2 * 2
5 is a prime number
6 equals 2 * 3
7 is a prime number
8 equals 2 * 4
9 equals 3 * 3
msg63386 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-03-08 09:47
Sorry, but I don't see a mismatch between code and output.
History
Date User Action Args
2022-04-11 14:56:31adminsetgithub: 46510
2008-03-08 09:47:21georg.brandlsetstatus: open -> closed
resolution: not a bug
messages: + msg63386
2008-03-08 01:42:26rhettingersetassignee: georg.brandl -> rhettinger
nosy: + rhettinger
2008-03-08 00:40:07Kyte999create