sorted unique elements from a list; using 2.3 features
Peter Abel
p-abel at t-online.de
Thu Jan 9 16:34:19 EST 2003
Andrew Dalke <adalke at mindspring.com> wrote in message news:<avbltt$kb4$1 at slb0.atl.mindspring.net>...
Hi Andrew,
Im using Python 2.2.2 and without the 2.3. - features the
following seems to work fine:
>>> input=[5, 3, 1, 2, 5, 4, 3, 4, 1, 1, 5, 4, 5, 1, 4, 3, 2, 2, 4, 1]
>>> output=dict( zip(input ,range(len(input)) ) ).keys()
>>> output
[1, 2, 3, 4, 5]
What Im wondering about is the fact that in several examples
even without the statment:
>>> output.sort()
I always got a sorted output.
Cheers Peter
More information about the Python-list
mailing list