So I've come across the code below here, and I can't wrap my head around how the return statements work. operation
is an argument in the functions seven
and five
but it's used as a function call in the return
statements. What's happening here?
The code is :
def seven(operation = None):
if operation == None:
return 7
else:
return operation(7)
def five(operation = None):
if operation == None:
return 5
else:
return operation(5)
def times(number):
return lambda y: y * number
Edit: following @chepner comment this is how they are called, for example this:
print(seven(times(five())))