LAMBDA EXPRESSIONS
Listing 3.13 shows the content of Lambda1.py, which illustrates how to create a simple lambda function.
Listing 3.13: Lambda1.py
add = lambda x, y: x + y
x1 = add(5,7)
x2 = add('Hello', 'Python')
print(x1)
print(x2)
Listing 3.13 defines the lambda expression add that accepts two input parameters and then returns their sum (for numbers) or their concatenation (for strings).
The output from Listing 3.13 is as follows:
12
HelloPython