Unique Elements in a List

runes rune.strand at gmail.com
Mon May 9 19:01:02 EDT 2005


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




More information about the Python-list mailing list