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: Error in Python tutorial (http://docs.python.org/tut/node6.html)
Type: Stage:
Components: Documentation Versions: Python 2.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: amaury.forgeotdarc, georg.brandl, sandeepsabnani
Priority: normal Keywords:

Created on 2008-04-30 08:47 by sandeepsabnani, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg65996 - (view) Author: Sandeep Sabnani (sandeepsabnani) Date: 2008-04-30 08:47
Section 4.4 on page http://docs.python.org/tut/node6.html has a for loop
which uses the range function. However, the displayed output of that
loop is not correct. I ran the same code and got the output as follows:

3 is a prime number
4 = 2 * 2
5 is a prime number
5 is a prime number
5 is a prime number
6 = 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 = 2 * 4
9 is a prime number
9 = 3 * 3

Can this be corrected in the tutorial as it can be confusing for a
python newbie!

Thanks!
msg65997 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-04-30 09:02
No, the example is correct, and gives the expected output.

From the output you show, I suppose that you indented the "else:" clause
incorrectly: it should align with the "for" loop, not the "if" statement.

The "for...else.." construct is precisely the point of this paragraph.
msg65998 - (view) Author: Sandeep Sabnani (sandeepsabnani) Date: 2008-04-30 09:52
Oh yes! Thanks for clearing my doubt and apologies for the silly error.
History
Date User Action Args
2022-04-11 14:56:33adminsetgithub: 46976
2008-04-30 09:54:08sandeepsabnanisetmessages: + msg65998
2008-04-30 09:02:24amaury.forgeotdarcsetstatus: open -> closed
nosy: + amaury.forgeotdarc
resolution: not a bug
messages: + msg65997
2008-04-30 08:47:40sandeepsabnanicreate