On Tue, Oct 21, 2008 at 8:47 AM, Richard Lovely <[EMAIL PROTECTED]> wrote: > Guessing you mean [5,100] as the inclusive interval notation, so all > but the last element of the example pass? > > if any(True for x, y in listoflists if 5 <= x and y <= 100): > #do stuff
or if any((5 <= x and y <= 100) for x, y in listoflists): > You can be slightly faster (but less readable) by changing the > if any(...): > to > if [...]: Why faster? any() will short-circuit - it will stop processing as soon as it finds a True item. It also avoids building the entire list. I would expect it to be faster. Of course, if you really care about speed you should test, not guess. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor