Unique Elements in a List
Aahz
aahz at pythoncraft.com
Mon May 9 21:14:43 EDT 2005
In article <1115679662.521731.297510 at f14g2000cwb.googlegroups.com>,
runes <rune.strand at gmail.com> wrote:
>
>This is not the most beautiful idiom, but it works...
>
>d = {}
>for k in data:
> try:
> d[k] += 1
> except:
> d[k] = 1
>
>for k,v in d.items():
> if v == 1:
> print k
Only if "works" does not include "order preserving".
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"And if that makes me an elitist...I couldn't be happier." --JMS
More information about the Python-list
mailing list