On Sat, Jul 30, 2011 at 2:15 PM, Asif Jamadar <asif.jama...@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?
def in_range(number) : return any(map(lambda (x,y) : x <= number <= y, ((0,10),(11,20), (21,30), (31,40)))) assert in_range(-5) == False assert in_range(0) == True assert in_range(5) == True assert in_range(10) == True assert in_range(10.5) == False assert in_range(11) == True assert in_range(40) == True assert in_range(41) == False If the above test cases (asserts) don't match your expectations, the code may need to be changed correspondingly. _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers