List Comprehension

Noun · Development

Definitions

  1. A concise syntactic construct for creating lists by applying an expression to each item in an iterable, optionally filtering with a condition — common in Python, Haskell, and similar languages.

    In plain English: A shortcut for building a new list by looping through items and picking or transforming the ones you want, all in a single line.

    Example: "[x*2 for x in range(10) if x % 2 == 0] — one line instead of five."

Related Terms