# 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))
Here is what the above code is Doing:
1. We have a function addition that takes a number as an argument and returns the double of that number.
2. We have a tuple of numbers.
3. We use the map function to double all the numbers in the tuple.
4. We convert the map object to a list and print it.