I am trying to reverse the index given by enumerate
whilst retaining the original order of the list being enumerated.
Assume I have the following:
>> range(5)
[0, 1, 2, 3, 4]
If I enumerate this I would get the following:
>> list(enumerate(range(5)))
[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)]
However I want to reverse the index provided by enumerate so that I get:
[(4, 0), (3, 1), (2, 2), (1, 3), (0, 4)]
So far I have the following code:
reversed(list(enumerate(reversed(range(5)))))
I was just wondering if there was a neater way to do this?