Python map() Function
Processing Iterables Without a using a Loop (Python)
in Many Programming Language such as JavaScript, Golang etc. map is a higher order Function that applies a given function and iterable the element one by one from the list , array , dict and set etc. the map function get element one by one from the list of dict and set on which the map function apply and send the element to the specified function which is given or pass the first args/parameter of the map.
Syntax of Map Function
map(any_function, iterables[list,dict,set ect])
Find the Squared of the list element by using map function with lambda
lst = [1,2,3,4,5,6,7,8,9]
squared = map(lambda x:x**2 , lst)
print(list(squared))
output like this
[1, 4, 9, 16, 25, 36, 49, 64, 81]
Square is a Transformation Function that maps the each elements with its square value.
the map() function apply the lambda square function all the element of the iterable list return iterator that yield of square value.