4 ms·
Just enclose the anonymous function with "(" and ")". Then you can use an anonymous function longer than one line. >>> f = lambda x: (x * x
by sgt 15y ago
Just enclose the anonymous function with "(" and ")". Then you can use an anonymous function longer than one line.
>>> f = lambda x: (x
* x
* x)
>>> f
<function <lambda> at 0x108cf3230>
- jamiltron 15y agoYes, but unfortunately it can only be a single expression.