Is it possible to have multiple statements in a python lambda expression?

后端 未结 18 1966
感情败类
感情败类 2020-12-12 21:33

I am a python newbie trying to achieve the following:

I have a list of lists:

lst = [[567,345,234],[253,465,756, 2345],[333,777,111, 555]]

18条回答
  •  臣服心动
    2020-12-12 22:18

    Using begin() from here: http://www.reddit.com/r/Python/comments/hms4z/ask_pyreddit_if_you_were_making_your_own/c1wycci

    Python 3.2 (r32:88445, Mar 25 2011, 19:28:28) 
    [GCC 4.5.2] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> lst = [[567,345,234],[253,465,756, 2345],[333,777,111, 555]]
    >>> begin = lambda *args: args[-1]
    >>> list(map(lambda x: begin(x.sort(), x[1]), lst))
    [345, 465, 333]
    

提交回复
热议问题