If two list is having same number, then the final list should not have the number
Advertisement
Answer
Check this code:
JavaScript
x
14
14
1
ls=[1,2,3,4,5,5]
2
ls1=[1,2,3,4,5,7,8,9]
3
4
common_elements=set(ls).intersection(set(ls1))
5
6
for i in common_elements:
7
if ls.__contains__(i):
8
ls.remove(i)
9
if ls1.__contains__(i):
10
ls1.remove(i)
11
12
final_ls=ls+ls1
13
print(final_ls)
14