6/14/2018 - 7:32 AM

Python enumerate

Enumerate is a built-in function of Python. It’s usefulness can not be summarized in a single line. Yet most of the newcomers and even some advanced programmers are unaware of it. It allows us to loop over something and have an automatic counter. Here is an example:

for counter, value in enumerate(some_list):
    print(counter, value)