Send As SMS

5/25/2006

find all the unique elements in a python list

say we have the python list:

>>x = [5,6,5]
to remove the duplications, use the following code snippet:
>>x_nodups = dict(map(lambda i: (i,1),x)).keys()
::thanks to walter underwood::


0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home

My blog has moved! Redirecting...

You should be automatically redirected. If not, visit http://stinkpot.afraid.org:8080/tricks/ and update your bookmarks.