Calmcode - lambda: functions

Functions

1 2 3 4 5

Python functions are much like normal variables.

def double(x):
    return x * 2

def add_one(x):
    return x + 1

I can put these two functions in a list.

function_list = [double, add_one]

These functions have not executed just, but I can keep them around to run later. That's what is happening in this block of code;

number = 1
for func in [add_one, double, add_one]:
    number = func(number)
    print(number)

Make sure that you understand what is happening in this block of code.