what is python enumerate code example
Example 1: enumerate in python
languages = ['Python', 'C', 'C++', 'C#', 'Java']
i = 0
for language in languages:
print(i, language)
i+=1
for i, language in enumerate(languages):
print(i, language)
Example 2: how to use enumerate in python
rhymes=['check','make','rake']
for rhyme in enumerate(rhymes):
print(rhyme)
(0, 'check')
(1, 'make')
(2, 'rake')
Example 3: for enumerate python
for key, value in enumerate(["p", "y", "t", "h", "o", "n"]):
print key, value
"""
0 p
1 y
2 t
3 h
4 o
5 n
"""