Python
List and Set Comprehensions
A comprehension builds a collection from an expression and a loop, in one line. It reads left to right in the same order as the loop it replaces.
List, set and dictionary comprehensions, conditions, nesting and when to stop using them.
2 notes
A comprehension builds a collection from an expression and a loop, in one line. It reads left to right in the same order as the loop it replaces.
The same syntax as a list comprehension, with a key and a value separated by a colon. It is the fastest way to build, filter, invert or reshape a mapp...