Looping in Python

How to use the enumerate() function in Python

Luay Matalka
Towards Data Science
3 min readSep 18, 2020

--

Photo by Florian Olivo on Unsplash

Introduction

Let’s say that we have a list. We want to iterate over this list, printing out the index followed by the list element or value at that index. Let’s accomplish this using a for loop:

num_list= [42, 56, 39, 59, 99]for i in range(len(num_list)): 
print(i…

--

--

Lead Machine Learning Engineer, specializing in MLOps, with a passion for teaching.