Thursday, December 3, 2026 | London 10°C · Drizzle
DailyGlimpse

AI

Python Devs Ditch range(len()) for This Elegant Trick

CodingWithMee 1 min read

Are you still using range(len(items)) in Python? There's a cleaner and more Pythonic way: enumerate(). With enumerate(), you get both the index and the item in a single loop, making your code easier to read and maintain.

for i, item in enumerate(items):
print(i, item)

This tip is a favorite among Python developers who value readability and efficiency. Next time you're iterating, give enumerate() a try!

React