The Day I Discovered List Comprehension

It was one of those late-night coding marathons. My script was running fine, but every time I looked at the for loop, something felt... heavy. squares = [] for _ in range(10): squares.append(_ * _) Wait... I wasn’t even using the variable for anything besides its own value. And even when I did need it, the loop itself just felt too verbose.

May 8, 2025 - 14:17
 0
The Day I Discovered List Comprehension

It was one of those late-night coding marathons.
My script was running fine, but every time I looked at the for loop, something felt... heavy.

squares = []
for _ in range(10):
    squares.append(_ * _)

Wait... I wasn’t even using the variable for anything besides its own value.
And even when I did need it, the loop itself just felt too verbose.