Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python lambda

# lambda functions creates small anonymous function
# create an add functions with that takes two numbers and returns the sum
add = lambda num1, num2: num1 + num2
print(add(9, 5))
# output 14

# double the numbers in a list
print(list(map(lambda num1: num1 * 2, [1, 2, 3, 4])))
# output [2, 4, 6, 8]
Source by codefreelance.net #
 
PREVIOUS NEXT
Tagged: #python #lambda
ADD COMMENT
Topic
Name
3+9 =