"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Is there an easy way to grab the Unique elements from a list? > For Example: > data = [0.1,0.5,0.6,0.4,0.1,0.5,0.6,0.9]
Untested: here's an iterator that gives you the index and value, without reordering. Uses dicts instead of sets for backwards compatibility. def unique_elements(data): seen = {} for n,x in data: if x not in seen: seen[x] = 1 yield n,x -- http://mail.python.org/mailman/listinfo/python-list