1

I can use enumerate with python dictionary like so:

for count, (key, value) in enumerate(my_dict.iteritems(), 1):
    print key, value, count

How do I use enumerate with the iteritems function from the six library?

user308827
  • 21,227
  • 87
  • 254
  • 417

1 Answers1

3

The six.iteritems equivalent of my_dict.iteritems() is six.iteritems(my_dict), so:

for count, (key, value) in enumerate(six.iteritems(my_dict), 1):
    print key, value, count
jwodder
  • 54,758
  • 12
  • 108
  • 124