Why use enumerate() instead of range() in your python's loops

Said BADAOUI
2 min readJan 7, 2021

enumerate() is faster when you want to repeatedly access the list/iterable items at their index. When you just want a list of indices, it is faster to use len() and range().

The range() function is often useful when iterating over a set of integers:

for n in range(200):
print(n)

#

for n in range(50, 110):
print(n)

--

--

Said BADAOUI

Full-stack developer & passionate blogger, using technology to bring ideas to life and sharing knowledge through writing. Constantly learning & improving skills