RSSAmplifier

galvanist · Jun 21, 2013

Python Reverse Enumerate

0
Sign in to vote or save

This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.

I want to save this thing I came across for future reference… a nice way to enumerate over an iterable in python in reverse order while retaining the proper indexes. 
 Here’s the issue. This code: 
 #!/usr/bin/python 
 
 WORDS = [ 'zero' , 'one' , 'two' ] 
 
 for index , string in enumerate ( reversed ( WORDS )): 
 print index , string 
 … prints…

Read on /posts/2013-06-21-python-reverse-enumerate/

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.