lambda function-br>
-In Python, anonymous function means that a function is without a name. As we already know that def keyword is used to define the normal functions and the lambda keyword is used to create anonymous functions.
Syntax-
lambda argument:expression
map() function-
-It is a python function which returns a list of the results after applying the given function to each item of a given iterable like list,tuple.
Syntax-
map(fun,iter)
Lambda with map function-
In map we require a function for argument, so at the place of the function, we create a lambda function.
Syntax-
map(lambda arg:exp,iter)
program-
#square the list by lambda
l=[1,2,3,4]
a=map(lambda x:x**2,l)
print("List is",l)
print("After sqaure of number, list is")
print(list(a))
#double the number
l=[4,3,2,1]
a=map(lambda x:x+x,l)
print("List is",l)
print("After double the number, list is")
print(list(a))
List is [1, 2, 3, 4]
After sqaure of number, list is
[1, 4, 9, 16]
List is [4, 3, 2, 1]
After double the number, list is
[8, 6, 4, 2]