[Tutor] Comparing more than 2 lists

Fiyawerx fiyawerx at gmail.com
Thu Jan 24 09:15:01 CET 2008


I have been able to find a few articles on comparing 2 lists, but I have 4
lists that I need to compare. I need to find any repeated elements and the
list that they came from. For example,

list1 = ['one', 'two', 'three']
list2 = ['one', 'two', 'four', 'five']
list3 = ['two', 'three', 'six', 'seven']
list4 = ['three', 'five', 'six']


I need to be able to get along the lines of output:
Element 'one' contained in list1 and list2
Element 'two' contained in list1 and list2 and list3
...
Element 'five' contained in list2 and list4

etc.. and I can't quite figure out how to go about it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080124/6f19f973/attachment.htm 


More information about the Tutor mailing list