Is every number in a list in a range?

MonkeeSage MonkeeSage at gmail.com
Tue Mar 6 03:51:21 CET 2007


On Mar 5, 7:24 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> This genexp is better than a loop because it bails out immediately
> if it finds an out-of-range x.

That's true: assuming that input is sequential. But if it's farily
random (e.g., [10, 20, 12, 46, 202, 5, 102]), then you need a loop/
list comp. to check each index.

Regards,
Jordan




More information about the Python-list mailing list