Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Replace list before iteration over map object

2
8
4
def double(n):
    return 2 * n

numbers = [1, 4, 2]

double_numbers = map(double, numbers)

numbers = [3, 7]
for num in double_numbers:
    print(num)