filtering elements from list of lists in Python?

后端 未结 7 796
鱼传尺愫
鱼传尺愫 2020-12-06 11:29

I want to filter elements from a list of lists, and iterate over the elements of each element using a lambda. For example, given the list:

a = [[1,2,3],[4,5         


        
7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 11:53

    You can do something like

    >>> a=[[1,2,3],[4,5,6]]
    >>> filter(lambda (x,y,z),: x+y+z>6, a)
    [[4, 5, 6]]
    

    Using the deconstruction syntax.

提交回复
热议问题