Python - enumerate()
Code Life
By Pierre Marsaa
What is enumerate()?
When you loop through a list with for, you get each element — but sometimes you also need its position (index). You could create a counter variable yourself...
↗️
Loading editor...
↶
↷
Or do it the other way around with range(len())...
↗️
Loading editor...
↶
↷
Both works, but Python has something better: enumerate().
Verify