← All tips

Python: list comprehensions for transforms

pythonbasics

Great for mapping one list to another.

nums = [1, 2, 3]
print([n * 2 for n in nums])