Skip to content

Latest commit

 

History

History
33 lines (22 loc) · 538 Bytes

LambdaExSupplementary.md

File metadata and controls

33 lines (22 loc) · 538 Bytes

syntax

lambda keyword followed by :

  • a comma-separated list of arguments
  • a colon
  • a single expression that returns the value of the function.
lambda x : x # this line does not transform the input, it simply returns it as is for the sake of the example
lowercase = lambda x: x.lower()

# equivalent representation
def lowercase(x):
    return x.lower()
square = lambda x: x * x

for el in range(1, 5):
    print(square(el))
equals_lambda = lambda x, y: x == y