Message70613
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'
... |
|
Date |
User |
Action |
Args |
2008-08-02 02:54:19 | yoshokun | set | recipients:
+ yoshokun, georg.brandl |
2008-08-02 02:54:19 | yoshokun | set | messageid: <1217645659.61.0.258873000656.issue3490@psf.upfronthosting.co.za> |
2008-08-02 02:54:18 | yoshokun | link | issue3490 messages |
2008-08-02 02:54:17 | yoshokun | create | |
|