I have file1 listed as :
-
er
we
ds,e3,kj
uy,mn
po
qw
pi
pi,f
File2 listed as :
-
df
we
wr
f,pi
ds,kj,e3
rt,uy
qw
po
I tried the following code ,but its not working as intended : -
my_set1 = set(x.strip() for x in (open('file1').readlines()))
print(my_set1)
my_set2 = set(x.strip() for x in (open('file2').readlines()))
print(my_set2)
my_list=list((set(my_set1).intersection(set(my_set2))))
print(my_list,"\n")
with open('common_signals','w') as file3:
for signal in my_list:
file3.write("%s\n" %signal)
Output I am getting inside commong signals is : - po ,we ,qw
.
It has NEGLECTED ds , kj
and e3 ,uy,pi,f
.
Can someone help on this ?