Given the list of sets s, I want to create the flattened_s as follows:
s = [{'a', 'b'}, {'c', 'd', 'e'}]
flattened_s = [['a', 'c'], ['a', 'd'], ['a', 'e'], ['b', 'c'], ['b', 'd'], ['b', 'e']]
This code can do the job:
flattened_s = []
for m in s[0]:
for n in s[1]:
flattened_s.append([m, n])
print(flattened_s)
However, if the list s is generalized to containing more than 2 sets in it, then how to do it? For example:
s = [{'a', 'b'}, {'c', 'd', 'e'}, {'f'}]