{2, 4, 6, 8}
# Python program to demonstrate working # of map. # Return double of n def addition(n): return n + n # We double all numbers using map() numbers = (1, 2, 3, 4) result = map(addition, numbers) print(list(result))
map(fun, iter)
x = ('key1', 'key2', 'key3') thisdict = dict.fromkeys(x) print(thisdict) #values are all None
for fruit, color in test.items(): # do stuff
x = ('key1', 'key2', 'key3') y = 0 thisdict = dict.fromkeys(x, y) print(thisdict)
Returns a list of the results after applying the given function to each item of a given iterable (list, tuple etc.)