diff lists
Carel Fellinger
cfelling at iae.nl
Wed Mar 28 15:17:59 EST 2001
Oliver Vecernik <vecernik at aon.at> wrote:
> Hi,
> I've got following two lists:
> ['a', 'b', 'c', 'd', 'e', 'f']
> ['e', 'c', 'f']
> I'd like to have the result:
> ['a', 'b', 'd']
> The list need not to be ordered. ['d', 'a', 'b'] will also be ok. What
> is the most effective way to achive that result?
Like proposed in an other thread, dicts are nice to uniquize lists, like:
d = {}
for k in a:
d[k] = 1
for k in b:
try:
del d[k]
except:
d[k] = 1
c = d.keys()
--
groetjes, carel
More information about the Python-list
mailing list