If we have a for
loop that converts one list to another list using a transformation for each element:
doubled_numbers = []
for n in numbers:
doubled_numbers.append(n * 2)
We can make that into a list comprehension by copy-pasting the assignment, the append value, and the for
clause: