Is every number in a list in a range?

MonkeeSage MonkeeSage at gmail.com
Mon Mar 5 22:30:07 EST 2007


On Mar 5, 9:19 pm, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> OK, I didn't read the question that way.  I thought the person just
> wanted a yes or no answer to whether the list contained any elements
> outside the desired range.  If the purpose is to select the elements
> in the range, then use filter/ifilter or a different listcomp/genexp:
>
>    inrange = [x for x in ll if 0<=x<=maxnum]

Well, the OP didn't actually specify what behavior they wanted. I was
just trying to go the with broadest case, with arbitrary values.

Regards,
Jordan




More information about the Python-list mailing list