[docs] About loops
georg at python.org
Sun Oct 6 11:26:34 CEST 2013
-----BEGIN PGP SIGNED MESSAGE-----
Am 05.07.2013 14:26, schrieb Blanca Mancilla:
> Hi, In section 4.4 break and continue Statements and else Clauses in loops,
> the first program has an issue: the second for: for x in range(2,n) is not
> entered in the first iteration of the n for (for n in range(2,10)) as range
> (2,2) give an empty range:
> therefore 2 is never "declared" prime.
> Also the break is in the wrong place.
if you look closely at the source, the "else" clause belongs to the "for"
loop. If you indent the clause correctly, the code will work as expected.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.21 (GNU/Linux)
-----END PGP SIGNATURE-----
More information about the docs