0
What is the benefit of this ' : ' in this code?
def my_func(f, arg): return f(arg) 👇 my_func(lambda x: 2*x*x, 5)
2 Respuestas
+ 2
The lambda is just a function, like those you define with "def". They just don't have a name.
Before the colon (:) you put all the parameters (like with "def"), after it you put what the function does.
In other words,
def foo(x, y):
return x + y
and
foo = lambda x, y: x + y
are more or less the same thing.
0
thank u all☺