Comprehensions build collections declaratively in one readable expression: Kind Syntax list [expr for x in it if cond] set {expr for x in it} dict {k: v for k, v in pairs} generator (expr for x in it) — lazy, no list in memory Conditional value goes before for ([a if c else b for …]); a filter goes after ([x for x in xs if c]). Generators A function containing yield returns a generator that produces values on demand. They are perfect for large files, infinite sequences and pipelines because only one item exists at a time. yield from other delegates to another iterable. itertools islice, chain, groupby, accumulate, product, permutations, combinations, batched (3.12) — lazy building blocks for iteration. Keep comprehensions short. If you need nested loops and conditions, a regular loop is…