Change list before iteration over map object
A small warning. Because map only connects to our iterator, but does not iterate over it till it is called, if we change the content of the underlying iterator, that will be reflected in the results of the iteration over the map object.
def double(n): return 2 * n numbers = [1, 4, 2] double_numbers = map(double, numbers) numbers.append(5) for num in double_numbers: print(num)
2 8 4 10