Convert list to another form but providing same information

Ian Kelly ian.g.kelly at gmail.com
Mon Mar 21 16:14:23 EDT 2016


On Mon, Mar 21, 2016 at 2:12 PM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> On Mon, Mar 21, 2016 at 2:03 PM, Ben Bacarisse <ben.usenet at bsb.me.uk> wrote:
>> For experts here: why can't I write a lambda that has a statement in it
>> (actually I wanted two: lambda l, i: l[i] += 1; return l)?
>
> https://docs.python.org/3/faq/design.html#why-can-t-lambda-expressions-contain-statements

tl;dr: If you want a function with a statement in it, use def, not lambda.



More information about the Python-list mailing list