+ 2

How to use enumerate?

I remember I learnt this but I forgot what it means and forgot where I learnt it. Can someone please explain what it does and give an example? Or just tell me what section to find it in. All help appreciated.

2nd Dec 2017, 12:42 PM
Max S
4 Réponses
+ 3
So bascially enumerate() creates an enumeration object, but to get around it, you can use tuple, list, etc. Its function: For every element in the list, it replaces it with a tuple containing the element's index followed by the element. For example, a=[1,2,3,5] print(list(enumerate(a))-->[(0,1),(1,2),(2,3),(3,5)]
2nd Dec 2017, 12:47 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
Thanks!
2nd Dec 2017, 12:49 PM
Max S
0
I've gotta thank you too! After a long time I got my answer marked as best answer!
2nd Dec 2017, 1:00 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
0
😏
2nd Dec 2017, 1:00 PM
Max S