+ 2
What use of map() function in python?
2 Respostas
+ 6
https://www.google.com/amp/s/www.geeksforgeeks.org/JUMP_LINK__&&__python__&&__JUMP_LINK-map-function/amp/...
Check thz Aashiq Ahmed ..
Happy learning ☺️
+ 6
#You can use map to call a function for each item in a list. And it will return an iterable object of the returned values.
new_list = list(map(func, [4, 7, 5, 0, 3]))
#corresponds:
new_list = [func(4), func(7), func(5), func(0), func(3)]
#Using map function is faster in runspeed than using for loop for the same purpose:
new_list = []
for item in [4, 7, 5 0, 3]:
new_list.append(item)
#But using list comprehension is also fast:
new_list = [func(item) for item in [4, 7, 5, 0, 3]]