+ 3

Help me understand why these lists are not doing the same thing.

https://code.sololearn.com/c9A11a8A251A/?ref=app

22nd Feb 2021, 6:56 PM
Zokalyx
Zokalyx - avatar
3 Answers
+ 2
by doing i(1) you assign x argument with 1, as you're accessing lambdas... so first case return always 2 (last item of range * x), while second return [0*1,1*1,2*2] ;)
22nd Feb 2021, 7:22 PM
visph
visph - avatar
+ 1
You can see that lambda as: def f(x): global i return i*x
22nd Feb 2021, 7:31 PM
Angelo
Angelo - avatar
- 1
Hi
22nd Feb 2021, 11:31 PM
Samson