Find the first element that meets the condition

Troy Melhase troy.melhase at gmail.com
Sun Feb 25 05:34:02 EST 2007


> I have implemented it this way, may be, there should be a built in
> hiding somewhere in the standard libraries?

the itertools module might have what you're after.  something similar
to your example:

>>> import itertools
>>> r = iter(range(100))
>>> n = itertools.dropwhile(lambda x:x<=13, r)
>>> n.next()
14



More information about the Python-list mailing list