I have a few lists
A =['D','KIT','SAP'],
B= ['F','G','LUFT','SAP'],
C= ['I','SAP'],
D= ['SAP','LUF','KIT'],
F= ['SAP','LUF','KIT','HASS']
I passed them in combinations to a dictionary. For example, I joined lists A and B as a key 'AB' in my new dictionary and appended the values from both lists like the list of values to that key 'AB'.
my_dict={"AB":[['D','KIT','SAP'],['F','G','LUFT','SAP']]}
My aim to get the overlap between the lists in multiple combination. For that, I could get with the following one liner.
for k,v in my_dict.items():
print(k,list(set.intersection(*[set(x) for x in v])))
AB ['SAP']
However, the problem here is that when I have more lists and more combinations it is tedious to define manually a dictionary with all possible combinations.
The aim is to achieve all possible combinations of lists. From the above-mentioned example, I have the following combination of lists. In this case that would be 5*5 +1 = 26 combinations. And in the end, I would like to get the overlap for each of the following combinations.
AB, AC, AD, AF
ABC, ABD, ABF
ABCD, ABCDF
ABCDF
BC, BD, BF
DF, DC
FC
The question is how could I achieve that in a pythonic way. Any suggestions are much appreciated.
As a side note, I do not want a dictionary in between if this combination of overlap is possible from the lists itself.
Thanks