Python -Intersection of multiple lists?

Legend picture Legend · Oct 4, 2010 · Viewed 53.1k times · Source

I am playing with python and am able to get the intersection of two lists:

result = set(a).intersection(b)

Now if d is a list containing a and b and a third element c, is there an built-in function for finding the intersection of all the three lists inside d? So for instance,

d = [[1,2,3,4], [2,3,4], [3,4,5,6,7]]

then the result should be

[3,4]

Answer

SingleNegationElimination picture SingleNegationElimination · Oct 4, 2010
set.intersection(*map(set,d))