Is every number in a list in a range?
Tue Mar 6 04:03:31 CET 2007
"MonkeeSage" <MonkeeSage at gmail.com> writes:
> > 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.
Maybe I didn't undrestand the question. Say maxnum is 30 in your
example above. Then as soon as 46 is seen, you can stop checking, I
More information about the Python-list