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

后端 未结 18 1934
感情败类
感情败类 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:09

    I'll give you another solution, Make your lambda invoke a function.

    def multiple_statements(x, y):
        print('hi')
        print('there')
        print(x)
        print(y)
        return 1
    
    junky = lambda x, y: multiple_statements(x, y)
    
    junky('a', 'b');
    

提交回复
热议问题