I don't understand about "enumerate" function


Right now I'm stuck at Loops: 15/19: counting as you go
Actually I'm not getting this "enumerate" function. I mean what its actual work in real life coding...

Could anyone please make me understand this in brief... about why is it important and whats its actual work in real life coding?

Thanks in advance



Simply put, it gives you access to the index of the items you are iterating through.


a = 'abcdef'
for index, letter in enumerate(a):
    print(letter, index)

This is just a way to simplify your code.



hmm k thanks. So you are saying that its okay. I mean its not that much important????


It's all important. Programming languages are not smorgasboards where we can pick and choose to our liking. Either delight in learning new things and treat them with equal importance or you will find yourself at the bottom of the ladder with no chance to climb higher. Throw away the blinders and don't hobble yourself. The only one to miss out on success will be you.