Python: using list comprehensions

Example:

numbers = [1, 2, 3, 4, 5]
Python list comprehensions provide a concise way to create lists.

Solution:

squared = [x**2 for x in numbers]

Beginner's Guide to Python