Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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
Source by treyhunner.com #
 
PREVIOUS NEXT
Tagged: #enumerate #items #python
ADD COMMENT
Topic
Name
3+9 =