[Tutor] single key ordered sequence
Senthil Kumaran
orsenthil at gmail.com
Thu Jan 15 18:56:39 CET 2009
> Also, how to practically walk in reverse order in a list without
> copying it (e.g. items[::-1]),
> especially if i need both indexes and items (couldn't find with
> enumerate()).
>
Are you looking for reversed()?
The way you are doing it is probably OK.
But it can be simplified thus:
keys = []
target = []
for item in reversed(items):
if not item[0] in keys:
keys.append(item[0])
target.append(item)
print target
If this is not what you wanted,then I have misunderstood your
requirement and just based it on your code.
Thanks,
Senthil
More information about the Tutor
mailing list