Python Lambda Expressions & Anonymous Functions

General way to create lambda expressions

lambda x1, x2, ..., xn: <expression>

Start The python interpreter

$ python3
>>>

Create test data

>>> colors = [ 'red', 'green', 'blue', 'pink', 'yellow', 'light green' ]
>>> data = [ 1, 2 ,3, 4 ,5, 6, 7, 8 ] 

Create a lambda function (4x + 2)

>>> z = lambda x: 4x + 1
>>> z(25)

Create a lambda function to combine two strings (first and last name?)

>>> n = lambda fn,ln: fn.strip().title() + ' ' + ln.strip().title()
>>> n('  tom', '  SWIFT  ')