On Jan 31, 2:48 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > On Jan 31, 8:12 am, erikcw <[EMAIL PROTECTED]> wrote: >
> One way would be to use sets and check for intersection: > > for idx, s in enumerate(mysets): > for next_idx, next_s in enumerate(mysets[idx+1:]): > if s.intersection(next_s): > print "mylist[%d] and mylist[%d] intersect" % ( > idx, idx + next_idx + 1 ) > Um, that would have been more helpful if I hadn't forgotten to preface that with: mylist = [(55, 58, 52), (20, 22, 18), (17, 21, 13), (60, 63, 57),] mysets = [set(range(x[2],x[1])) for x in mylist] -- Cheers, Steven -- http://mail.python.org/mailman/listinfo/python-list