The map() Function for Applying Functions to Iterables in Python


Apply a function to every item of an iterable.

Source Code

numbers = [1, 2, 3, 4]
squared = map(lambda x: x ** 2, numbers)
print(list(squared))
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments