Is every number in a list in a range?

Matimus mccredie at gmail.com
Mon Mar 5 16:34:50 EST 2007


On Mar 5, 11:03 am, "Steven W. Orr" <ste... at syslang.net> wrote:
> I have a list ll of intergers. I want to see if each number in ll is
> within the range of 0..maxnum
>
> I can write it but I was wondering if there's a better way to do it?
>
> TIA
>
> --
> Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
> happened but none stranger than this. Does your driver's license say Organ ..0
> Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
> individuals! What if this weren't a hypothetical question?
> steveo at syslang.net

I would probably do something using max and min functions like this:

seq = [...] # your list

if min(seq) >= 0 && max(seq) <= MAXNUM:
 do stuff




More information about the Python-list mailing list