News for hackers. Stuff that matters.
Re:Python List Comprehensions Explained Visually by msellout on Thursday December 03, 2015 @02:38AM (#10668334)
Perhaps a for-loop is more similar to your memory of other code, but a list comprehension is more similar to an English sentence.

    "All names longer than 4 characters in the list of cities?"
    all(len(name) > 4 for name in cities)

    "Sum of x-squared for x from 10 to 20."
    sum(x**2 for x in range(10, 20))

There are no comments on this comment yet.