Finding the insertion point in a list

Paul Rubin http
Sat Mar 17 07:42:27 CET 2007


Steven D'Aprano <steve at REMOVE.THIS.cybersource.com.au> writes:
> or even
> 
> len(filter(lambda t, y=y: y>t, x))


How about 

   min(i for i,t in enumerate(x) if t >= y)

or

   max(i for i,t in enumerate(x) if t <= y)

Those are actually pretty direct.



More information about the Python-list mailing list