[snip]
That's potentially very expensive for large lists, although simply
converting the lists to sets should give a significant speed up. I
think the following is *possibly* as good a way as any.
>>> def compare(list1, list2):
intersection = sorted(list(set(list1) & set(list2)))
for i in range(len(intersection) - 1):
if intersection[i] == intersection[i+1] - 1:
return True
return False
Duncan
Why it is potentially very expensive for large lists? what does intersection mean in Duncan's code? Thanks a lot for your patience!
--
Thanks!
Ben Bush
--
http://mail.python.org/mailman/listinfo/python-list