How to find common elements in list of lists?

后端 未结 7 1155
無奈伤痛
無奈伤痛 2020-11-27 18:13

I\'m trying to figure out how to compare an n number of lists to find the common elements. For example:

p=[ [1,2,3],
    [1,9,9],
      ..
      ..
    [1,2         


        
相关标签:
7条回答
  • 2020-11-27 19:14
    >>> p=[ [1,2,3],
        [1,9,9],
        [1,2,4]]
    >>> set(p[0]).intersection(*p)
    set([1])
    
    0 讨论(0)
提交回复
热议问题