In [1]:
numbers = [1, 2, 3, 4]
squares = []

for n in numbers:
  squares.append(n**2)

print(squares)
[1, 4, 9, 16]
In [2]:
numbers = [1, 2, 3, 4]
squares = [n**2 for n in numbers]

print(squares)
[1, 4, 9, 16]