python list

How to use python enumerate

Enumerate helps to track the index and element. Though we can gain the same feature using for loop but enumerate makes the code more readable Imagine we have a list of colors color_names = [‘Red’, ‘Orange’, ‘Yellow’, ‘Green’, ‘Blue’, ‘Purple’, ‘Pink’, ‘Brown’,’Cyan’] For tracking both the index and corresponding element we can write this simple […]