Mรณdulo 02 ยท Collections โ Lecciรณn 4 de 4 ยท ~8 min
Comprehensions
Build a list, in one line
A list comprehension builds a new list by transforming (and optionally filtering) another collection โ all in one expression instead of a loop with .append() calls:
names = [w["name"] for w in walkers]
Read it left to right: "give me w["name"], for each w in walkers." It's the Python equivalent of Swift's walkers.map { $0["name"] }.