python enumrate 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: enumerate python
for index,char in enumerate("abcdef"):
print("{}-->{}".format(index,char))
0-->a
1-->b
2-->c
3-->d
4-->e
5-->f
Example 3: enumerate in python
Return type: < type 'enumerate' >
[(0, 'eat'), (1, 'sleep'), (2, 'repeat')]
[(2, 'g'), (3, 'e'), (4, 'e'), (5, 'k')]