I don't understand about "enumerate" function


#1

Hi
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

--
Regards
Pradeep


#2

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

Example:

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

This is just a way to simplify your code.


#3

@zeziba

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


#4

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.