Sunday, 25 December 2016

What is Enumerate in Python?

Enumerate  function is used to iterate through a list while keeping track of the list items' indices.
Example : x = ('A', 'B', 'C')
                 for i,y in enumerate(x):
                Output: 0   A              #Indexing starts from 0 by Default  
                             1   B
                             2   C
1.By default enumerate counts from 0,but you could index it accordingly by providing 2nd argument.

Example:for i,y in enumerate(x,50): # 2nd argument value is set to 50
                Output: 50   A                     #Indexing starts from 50 as it is given as argument in function
                             51   B
                             52   C

Bored of Learning ?Wanna go out on a tour(full of adventures,excitement) please visit .