Python Tutorial

Thursday, December 12, 2013

Python enumerate

enumerate returns a tuple containing a count (from start which defaults to 0) and the values obtained from iterating over sequence.
a = ["Python","easy"]

for i, n in enumerate(a):
    print i, n


Output:
0 Python
1 easy

0 comments:

Post a Comment