例如,
(['2', '3', '5'], ['1', '3', '4', '5'])
上面应该产生数字 3 和 5
(['1', '2', '4'], ['1', '2'])
这应该给出 1 , 2
(['2', '3', '5'], ['1', '2', '4'], ['2', '3'])
这个,应该给出 2,因为 2 包含在元组的所有 3 个列表中。如果没有集合,它应该只返回一个空列表
for i,e in enumerate(tup):
while index < len(tup):
print(tup[index], tup[index + 1])
index = index + 1
现在我有了这个,我不确定如何遍历 tup(Tuple) 并提取每个列表以找到每 2 个列表的集合并迭代并与元组中的其余列表进行比较
请您参考如下方法:
def intersect(lists):
return list(set.intersection(*map(set, lists)))
