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)

23rd May 2018, 5:30 PM
Omar
Omar - avatar
2 Answers
+ 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.
23rd May 2018, 5:36 PM
Schindlabua
Schindlabua - avatar
0
thank u allâ˜ș
23rd May 2018, 5:46 PM
Omar
Omar - avatar