+ 6
I need help understanding this example from w3Schools about using Lambdas.
Hello, I need help understanding this code from w3schools about lambdas. I'm mainly confused on which argument is being sent to which parameter. https://code.sololearn.com/c6M7D403nfiA/?ref=app
8 Answers
+ 3
yes... not easy.
https://code.sololearn.com/cf82YL47x32r/?ref=app
+ 2
Rithea Sreng
Oma Falk
Bilbo Baggins
Thanks, I wanted to write down the steps to make sure what was going on line by line. Let me know if I made any mistake.
https://code.sololearn.com/c12uDWhYc2Y8/?ref=app
+ 1
This is such as a reference.
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2460/
+ 1
Ja Play
Thanks for the link explaining a bit more on lambas.
However, SoloLearn just has examples of taking 1 argument. The example from w3schools takes in multiple arguments which is a bit confusing for me to understand.
+ 1
Also our lambda has just one argument, "a".
But it has also an unknown variable, "n", passed by function myfunc()
So mydoubler = myfunc(2) can be replaced with
def mydoubler:
return lambda a : a * 2
or even, instantiating the lambda,
def mydoubler(a):
return a*2
0
lambda is an anonymous function