In the last lesson, you saw how you can make your loops more Pythonic by iterating over items from a container directly, but what if you need to keep track of the item index?
In this lesson, you’ll see how you can use
enumerate() to keep track of a running index the Pythonic way.
enumerate() is a generator that returns a running index as well as the actual element or item in the container.
AMithKS on July 21, 2019
Can I customize
enumerate()for any container like a binary tree, where the index-like value is equivalent to node value?