python enumerate items in list code example
Example 1: python enumerate list
>>> for count, value in enumerate(values):
... print(count, value)
...
0 a
1 b
2 c
Example 2: enumerate items python
mydict = {1: 'a', 2: 'b'}
for i, (k, v) in enumerate(mydict.items()):
print("index: {}, key: {}, value: {}".format(i, k, v))
# which will print:
# -----------------
# index: 0, key: 1, value: a
# index: 1, key: 2, value: b