# squares.map.py # This is not a valid Python module - Don't run it. # If you code like this you are not a Python dev! ;) >>> squares = [] >>> for n in range(10): ... squares.append(n ** 2) ... >>> squares [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] # This is better, one line, nice and readable >>> squares = map(lambda n: n**2, range(10)) >>> list(squares) [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]