Unique Elements in a List

James Stroud jstroud at mbi.ucla.edu
Mon May 9 19:24:39 EDT 2005


On Monday 09 May 2005 03:15 pm, superprad at gmail.com wrote:
> Is there an easy way to grab the Unique elements from a list?

from sets import Set

data = [0.1,0.5,0.6,0.4,0.1,0.5,0.6,0.9]

[x for x in Set(data) if data.count(x) == 1]

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/



More information about the Python-list mailing list