Re: Weird behavior in search in a list

2007-03-30 Thread Hendrik van Rooyen
"Su Y" <[EMAIL PROTECTED]> wrote: > I want find the first number in extend[] which is larger than num, so > I wrote: > def find(num): > count=0 > for elem in extend: > if elem count+=1 > return count > > I found that if extend[] is monotonous, like [1.1, 2.3, 3.2,

Re: Weird behavior in search in a list

2007-03-29 Thread Su Y
On 3月29日, 下午8时22分, Michael Bentley <[EMAIL PROTECTED]> wrote: > On Mar 29, 2007, at 6:51 AM, Su Y wrote: > > > > > > > I want find the first number in extend[] which is larger than num, so > > I wrote: > > def find(num): > > count=0 > > for elem in extend: > > if elem >

Re: Weird behavior in search in a list

2007-03-29 Thread Amit Khemka
On 3/29/07, Michael Bentley <[EMAIL PROTECTED]> wrote: > > On Mar 29, 2007, at 6:51 AM, Su Y wrote: > > > > I want find the first number in extend[] which is larger than num, so > def find(num): > # check to make sure there *is* a value greater than num > if max(extend) > num: >

Re: Weird behavior in search in a list

2007-03-29 Thread Michael Bentley
On Mar 29, 2007, at 6:51 AM, Su Y wrote: > > I want find the first number in extend[] which is larger than num, so > I wrote: > def find(num): > count=0 > for elem in extend: > if elem count+=1 > return count > > I found that if extend[] is monotonous, like [1.1, 2.

Re: Weird behavior in search in a list

2007-03-29 Thread Josh
"Su Y" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] On 3ÔÂ29ÈÕ, ÏÂÎç7ʱ51·Ö, "Su Y" <[EMAIL PROTECTED]> wrote: > hi all, > I can't understand how this code work, its behavior is really weird > for me... > > I want find the first number in extend[] which is larger than num, soI > w

Re: Weird behavior in search in a list

2007-03-29 Thread Amit Khemka
> On 29 Mar 2007 04:51:00 -0700, Su Y <[EMAIL PROTECTED]> wrote: > > I want find the first number in extend[] which is larger than num, so > On 3/29/07, Amit Khemka <[EMAIL PROTECTED]> wrote: > Btw a concise way could be: > def getfirstbigger(num): > for i,x in enumerate(extend): > i

Re: Weird behavior in search in a list

2007-03-29 Thread Amit Khemka
On 29 Mar 2007 04:51:00 -0700, Su Y <[EMAIL PROTECTED]> wrote: > hi all, > I can't understand how this code work, its behavior is really weird > for me... > > I want find the first number in extend[] which is larger than num, so > I wrote: > def find(num): > count=0 > for elem in extend: >

Re: Weird behavior in search in a list

2007-03-29 Thread Su Y
On 3月29日, 下午7时51分, "Su Y" <[EMAIL PROTECTED]> wrote: > hi all, > I can't understand how this code work, its behavior is really weird > for me... > > I want find the first number in extend[] which is larger than num, soI wrote: > > def find(num): > count=0 > for elem in extend: > if

Weird behavior in search in a list

2007-03-29 Thread Su Y
hi all, I can't understand how this code work, its behavior is really weird for me... I want find the first number in extend[] which is larger than num, so I wrote: def find(num): count=0 for elem in extend: if elem-- http://mail.python.org/mailman/listinfo/python-list