"OriginalBrownster" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

> I know this probably is a very easy thing to do in python, but i wanted
> to 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"]

Other people have already posted solutions but I'll add a couple of
comments:

1. Avoid calling lists 'list', you will break the list built-in function.

2. You don't specify whether the lists are ordered. If there is no
significance to the order of the items, it may be more appropriate
to use sets throughout. Then the answer is just: set3 = set1 | set2. 


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to