我有一个列表,其中包含具有不同名称和字符串值的多组{}。
例如
set1 = {"a", "santa", "clock"}
search = {"why", "is", "santa", "nice"}
list_of_sets = [set1, search]
我想通过函数在列表中找到集合之间的交集:
def intersection_between_sets_from_list(list_of_sets):
""" find the intersection between the sets here"""
return intersection_strings
任何想法在“”“中使用什么代码都可以在这里”“”找到集合之间的交集。
如果要在列表中找到所有集合之间的交集,可以在list_of_set
上进行迭代,并像这样找到当前集合与时间集合之间的交集: