problems with a for loop (noobie)

Russell Blau russblau at hotmail.com
Sat Jul 6 08:33:04 EDT 2002


"Charles Mantha" <charles_mantha at hotmail.com> wrote in message
news:1IsV8.42194$Fc1.850199 at wagner.videotron.net...
> Reading the Python Tutorial by Guido van Russom and there's an example
that
> I don't get, and seems to not be explained (at least not enought for me).
>
> >>> 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'
> ...

> ps : and for some reason, the output is not the same as in the tutorial
when
> I try this.

This is kind of hard to explain if we don't see the output that you saw.
Are you certain you typed it exactly as it appeared in the tutorial
(including indentation)?






More information about the Python-list mailing list