Iterating and enumerating on ordered dicts

by jenny on 13 February 2013 - 10:39pm in

Iterating with counter over items:

        for i, (key, value) in enumerate(ordereddict.items()):
            print i, key, value

Iterating with counter over keys:

        for i, key in enumerate(ordereddict.iterkeys()):
            print i, key

Iterating with counter over values:

        for i, value in enumerate(ordereddict.itervalues()):
            print i, value