Filtering a Python list to uniques

hellt Dodin.Roman at gmail.com
Wed Mar 26 05:45:17 EDT 2008


On 26 мар, 02:30, kellygreer1 <kellygre... at yahoo.com> wrote:
> What is the best way to filter a Python list to its unique members?
> I tried some method using Set but got some "unhashable" error.
>
> lstone = [ 1, 2, 3, 3, 4, 5, 5, 6 ]
> # how do i reduce this to
> lsttwo = [ 1, 2, 3, 4, 5, 6 ]
>
> Is there a page on this in the Python in a Nutshell or the Python
> Cookbook?
> Did I miss something?
>
> Kelly Greer
> kellygre... at nospam.com
> change nospam to yahoo


or just look this thread for a fastest solution
http://groups.google.com/group/comp.lang.python/browse_frm/thread/7091898414444310/af8961f1ed91ccea?lnk=gst&q=duplicates#af8961f1ed91ccea



More information about the Python-list mailing list