In resume, I have two keys in the same dictionary where each one has their corresponding lists.
I try to compare both list to check common and differential elements. It means that the output I will count how many elements are identical or present in only one key's list.
from the beginning I am inserting the elements using the files as arguments and they are read in the function
def shared(list):
dict_shared = {}
for i in list:
infile = open(i, 'r')
if i not in dict_shared:
dict_shared[i] = []
for line in infile:
dict_shared[spacer].append(record.id)
return dict_shared
Now I am stuck trying to find a way to compare the lists created and present in the dictionary.
dict = {a:[1,2,3,4,5], b:[2,3,4,6]}
My intention is to compare the lists in order to have the lines shared between two texts.
a: [1,5]
b: [6]
a-b: [2,3,4]
From now I can't find a way to solve this. Any suggestion?