Enumerate function. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Enumerate function.

Can anyone please explain this function with the help of an example? I'm having difficulty in understanding the example given in Sololearn...!!

25th Jul 2017, 2:59 PM
Suraj Potti
Suraj Potti - avatar
2 Answers
+ 8
enumerate() iterates through a collection and returns pairs of the element's index number and the element itself. collection = ["abc", "solo", "learn"] print(list(enumerate(collection))) The output will be: [(0, 'abc'), (1, 'solo'), (2, 'learn')]
25th Jul 2017, 6:46 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 4
https://www.programiz.com/JUMP_LINK__&&__python__&&__JUMP_LINK-programming/methods/built-in/enumerate Try this tutorial instead, I think the two examples there explain it pretty well (:
25th Jul 2017, 3:09 PM
Maya
Maya - avatar