delete duplicates in list

christof hoeke csad7 at
Wed Oct 29 22:02:08 CET 2003

this must have come up before, so i am already sorry for asking but a 
quick googling did not give me any answer.

i have a list from which i want a simpler list without the duplicates
an easy but somehow contrived solution would be

 >>> a = [1, 2, 2, 3]
 >>> d = {}.fromkeys(a)
 >>> b = d.keys()
 >>> print b
[1, 2, 3]

there should be an easier or more intuitive solution, maybe with a list 

somthing like

 >>> b = [x for x in a if x not in b]
 >>> print b

does not work though.

thanks for any help

More information about the Python-list mailing list