> On 29 Mar 2007 04:51:00 -0700, Su Y <[EMAIL PROTECTED]> wrote:
<snip>
> > I want find the first number in extend[] which is larger than num, so
<snip>

> On 3/29/07, Amit Khemka <[EMAIL PROTECTED]> wrote:
> Btw a concise way could be:
> def getfirstbigger(num):
>     for i,x in enumerate(extend):
>         if x>num:    return i
>     return len(extend)

I forgot to add that you can as well 'return' the the item (along with
the index), but in case all the items in the list are smaller than the
argument, what return value do you require?
-- 
----
Amit Khemka -- onyomo.com
Home Page: www.cse.iitd.ernet.in/~csd00377
Endless the world's turn, endless the sun's Spinning, Endless the quest;
I turn again, back to my own beginning, And here, find rest.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to