[BangPypers] if not with comparision statement in python

Rajeev J Sebastian rajeev.sebastian at gmail.com
Mon Aug 1 10:38:32 CEST 2011


On Mon, Aug 1, 2011 at 12:08 PM, Anand Balachandran Pillai
<abpillai at gmail.com> wrote:
> On Sat, Jul 30, 2011 at 2:15 PM, Asif Jamadar <asif.jamadar at rezayat.net>wrote:
>
>> What if I have two lists for both minimum and maximum values
>>
>> Minimum  Maximum
>> 0               10
>> 11              20
>> 21              30
>> 31              40
>>
>>
>> Now how should I check if actual result is not laying between above ranges
>>
>> if not minimum<=actual_result and  not maximum>=actual_result:
>>
>> Any suggestions?
>>
>>
> Use zip.
>
>>>> minl=(0,11,21,31)
>>>> maxl=(10,20,30,40)
>>>> x = 5
>>>> for r in zip(minl, maxl):
> ...     if x in range(r[0], r[1]): print 'Found in range',r

flag = False
for min, max in zip(minl, maxl):
     if min <= x <= max:
          flag = True


return not flag


More information about the BangPypers mailing list