What is the best way to merge two lists?

Erik Max Francis max at alcyone.com
Sat Nov 16 22:56:23 EST 2002


Pierre Rouleau wrote:

> What's the most efficient way to merge two lists inside a single one
> with the resulting list having only one instance of each element (ie
> not
> having two elements with the same value)?

Go through both lists, adding each as a key in a dictionary.  Then, when
you're done, retrieve the keys from the dictionary.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ I want to know God's thought; the rest are details.
\__/ Albert Einstein
    Blackgirl International / http://www.blackgirl.org/
 The Internet resource for black women.



More information about the Python-list mailing list