Passing functions as parameters
def call(func):
return func(42)
def double(val):
print(2*val)
call(double) # 84
call(lambda x: print(x // 2)) # 21
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
def call(func):
return func(42)
def double(val):
print(2*val)
call(double) # 84
call(lambda x: print(x // 2)) # 21