Python: dictionary comprehensions

Example:

numbers = [1, 2, 3, 4, 5]
Dictionary comprehensions allow the creation of dictionaries using a similar syntax as list comprehensions.

Solution:

squares = {n: n**2 for n in numbers}

Beginner's Guide to Python