0
You can place a for loop inside a lambda function. how?
f = lambda x : x for... ?
3 Antworten
+ 4
f=lambda x: [i**2 for i in range(x)]
print(f(5))
+ 2
Well, the computer says no:
https://docs.python.org/2/reference/expressions.html#lambda
...but I guess you could encapsulate your loop into a function, and then use 'map' with this function... although that would miss the point of defining a lambda expression IMHO.
+ 1
Thank Alvaro.. there will be another way without using compression v list ?