Comprehensions: New Lists in One Line

A comprehension builds a new list, dictionary or set from another collection in one line, written as what goes in, for each item, if a condition holds, and replaces the empty-list-and-append loop whenever the whole job is building one collection.

By

Updated

Cheat sheet: Comprehensions: New Lists in One Line
Category
Python
Level
Apprentice
Tags
Dictionary Comprehension, List Comprehension, python, Set Comprehension