I define intersection of two lists as follows:
def intersect(a, b):
return list(set(a) & set(b))
For three arguments it would look like:
def intersect(a, b, c):
return (list(set(a) & set(b) & set(c))
Can I generalize this function for variable number of lists?
The call would look for example like:
>> intersect([1, 2, 2], [2, 3, 2], [2, 5, 2], [2, 7, 2])
[2]
EDIT: Python can only achieve it this way?
intersect([
[1, 2, 2], [2, 3, 2], [2, 5, 2], [2, 7, 2]
])
[2]