Difference of two lists
Had a problem to find the difference of list of elements in two files
So here is a solution:
with open("file1.txt") as f:
file_1_elements = f.read().splitlines()
with open("file2.txt") as f:
file_2_elements = f.read().splitlines()
def Diff(li1, li2):
return list(set(li1) - set(li2)) + list(set(li2) - set(li1))
print(Diff(file_1_elements,file_2_elements))
contents of file can be list of elements in each line
hello1
hello2
hello3