Re: basic python question about for loop

2008-04-12 Thread Steve Holden
jmDesktop wrote: [...] > So what is n and x in the first iteration? Sorry. I'm trying. Somewhat feebly, if you don't mind my saying so, but don't worry. The usual way to proceed in the face of such ignorance is to insert some form of output that will tell you the answer to your question. So:

Re: basic python question about for loop

2008-04-12 Thread Jason Stokes
"jmDesktop" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > So what is n and x in the first iteration? Sorry. I'm trying. Remember how Python's range operator works. range(n, x) constructs a list that consists of all elements starting with n and up to, but /not including/, x.

Re: basic python question about for loop

2008-04-09 Thread Terry Reedy
|So what is n and x in the first iteration? Sorry. I'm trying. When n == 2, the inner loop executes 0 times (the length of range(2,n)) and then falls thru to the else clause, printing the correct answer. -- http://mail.python.org/mailman/listinfo/python-list

Re: basic python question about for loop

2008-04-09 Thread Diez B. Roggisch
jmDesktop schrieb: > On Apr 9, 4:58 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: >> jmDesktop schrieb: >> >> >> >> >> >>> From the Python.org tutorial: >> for n in range(2, 10): >>> ... for x in range(2, n): >>> ... if n % x == 0: >>> ... print n, 'equals', x, '*',

RE: basic python question about for loop

2008-04-09 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of jmDesktop > Sent: Wednesday, April 09, 2008 5:04 PM > To: python-list@python.org > Subject: Re: basic python question about for loop > > > > > > >>&g

Re: basic python question about for loop

2008-04-09 Thread jmDesktop
On Apr 9, 4:59 pm, "Reedick, Andrew" <[EMAIL PROTECTED]> wrote: > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:python- > > [EMAIL PROTECTED] On Behalf Of jmDesktop > > Sent: Wednesday, April 09, 2008 4:51 PM > > To: [EMAIL PROTECTED

Re: basic python question about for loop

2008-04-09 Thread jmDesktop
On Apr 9, 4:58 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > jmDesktop schrieb: > > > > > > > From the Python.org tutorial: > > for n in range(2, 10): > > ...     for x in range(2, n): > > ...         if n % x == 0: > > ...             print n, 'equals', x, '*', n/x > > ...             b

Re: basic python question about for loop

2008-04-09 Thread Steve Holden
jmDesktop wrote: >>From the Python.org tutorial: > 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 > ...

RE: basic python question about for loop

2008-04-09 Thread Reedick, Andrew
> -Original Message- > From: [EMAIL PROTECTED] [mailto:python- > [EMAIL PROTECTED] On Behalf Of jmDesktop > Sent: Wednesday, April 09, 2008 4:51 PM > To: python-list@python.org > Subject: basic python question about for loop > > >From the Python.org tutorial

Re: basic python question about for loop

2008-04-09 Thread Diez B. Roggisch
jmDesktop schrieb: > From the Python.org tutorial: > 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 > ...

basic python question about for loop

2008-04-09 Thread jmDesktop
>From the Python.org tutorial: >>> 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' ..