+ 3
I don't undersrand why the output is 222!!!!
I see that with the definition I get a list with three functions, I think that 012 is the output expected but it is 222!!! Why? https://code.sololearn.com/ccyPlPxCFUXL/?ref=app
3 RĂ©ponses
+ 3
Thanks LDSD and Tibor Santa! The links worked to me! I got a better idea with the lambdas!
+ 2
You can read about it here, which is better explained than anything I could write:
https://stackoverflow.com/questions/139819/why-results-of-map-and-list-comprehension-are-different
Read up so you know why this behaviour is intended.
Then you can fix your lambda like this:
lambda x, u=i: u*x for i in range(3)
+ 2
Check this thread maybe it helps to get a better understanding.
https://www.sololearn.com/Discuss/2180319/?ref=app
I think this is pretty mean for a challenge question đ€
Really not trivial, but a good point that you have to be very careful with using lambda in comprehension.