[Stephen] > [...] compare 2 lists and generate a new list that does not copy similar > entries. An example below > > list= ["apple", "banana", "grape"] > list2=["orange","banana", "pear"] > > now I want to compare these lits and generate a third list after > comparison > > list3 would be ["apple", "banana","grape","orange", "pear"]
Use sets: >>> from sets import Set as set # For compatibility with Python 2.3 >>> one = ["apple", "banana", "grape"] >>> two = ["orange","banana", "pear"] >>> print list(set(one) | set(two)) ['grape', 'apple', 'orange', 'pear', 'banana'] -- Richie Hindle [EMAIL PROTECTED] -- http://mail.python.org/mailman/listinfo/python-list