In [1]:
l1 = ['a', 'b', 'c']
l2 = ['b', 'c', 'd']
l3 = ['c', 'd', 'e']

In [2]:
l1_l2_and = set(l1) & set(l2)
print(l1_l2_and)


{'c', 'b'}

In [3]:
print(type(l1_l2_and))


<class 'set'>

In [4]:
l1_l2_and_list = list(l1_l2_and)
print(l1_l2_and_list)


['c', 'b']

In [5]:
print(type(l1_l2_and_list))


<class 'list'>

In [6]:
print(len(l1_l2_and))


2

In [7]:
l1_l2_l3_and = set(l1) & set(l2) & set(l3)
print(l1_l2_l3_and)


{'c'}

In [8]:
l1_l2_sym_diff = set(l1) ^ set(l2)
print(l1_l2_sym_diff)


{'a', 'd'}

In [9]:
print(list(l1_l2_sym_diff))


['a', 'd']

In [10]:
print(len(l1_l2_sym_diff))


2

In [11]:
l1_l2_l3_sym_diff = set(l1) ^ set(l2) ^ set(l3)
print(l1_l2_l3_sym_diff)


{'c', 'a', 'e'}

In [12]:
l_all = l1 + l2 + l3
print(l_all)


['a', 'b', 'c', 'b', 'c', 'd', 'c', 'd', 'e']

In [13]:
print(set(l_all))


{'d', 'b', 'a', 'c', 'e'}

In [14]:
l_all_only = [x for x in set(l_all) if l_all.count(x) == 1]
print(l_all_only)


['a', 'e']

In [15]:
l1_duplicate = ['a', 'a', 'b', 'c']

In [16]:
l_duplicate_all = l1_duplicate + l2 + l3
l_duplicate_all_only = [x for x in set(l_duplicate_all) if l_duplicate_all.count(x) == 1]
print(l_duplicate_all_only)


['e']

In [17]:
l_unique_all = list(set(l1_duplicate)) + list(set(l2)) + list(set(l3))
print(l_unique_all)


['c', 'b', 'a', 'c', 'b', 'd', 'c', 'd', 'e']

In [18]:
l_uniaues_all_only = [x for x in set(l_unique_all) if l_unique_all.count(x) == 1]
print(l_uniaues_all_only)


['a', 'e']

In [19]:
l1_l2_or = set(l1 + l2)
print(l1_l2_or)


{'c', 'b', 'a', 'd'}

In [20]:
print(list(l1_l2_or))


['c', 'b', 'a', 'd']

In [21]:
print(len(l1_l2_or))


4

In [22]:
l1_l2_l3_or = set(l1 + l2 + l3)
print(l1_l2_l3_or)


{'d', 'b', 'a', 'c', 'e'}