Compare two lists and find duplicate that exist in both lists
from two lists remove the existing duplicates and create new lists.
Input
a= [
"DJI_0229.jpg",
"DJI_0232.jpg",
"DJI_0233.jpg"
"DJI_0235.jpg"
]
b= [
"DJI_0229.jpg",
"DJI_0232.jpg",
"DJI_0233.jpg"
"DJI_0230.jpg",
"DJI_0231.jpg",
"DJI_0234.jpg"
]
output =
[
"DJI_0230.jpg",
"DJI_0231.jpg",
"DJI_0234.jpg",
"DJI_0235.jpg"
]
>Solution :
you can do this
a= ["DJI_0229.jpg","DJI_0232.jpg","DJI_0233.jpg","DJI_0235.jpg"]
b= ["DJI_0229.jpg","DJI_0232.jpg","DJI_0233.jpg","DJI_0230.jpg","DJI_0231.jpg","DJI_0234.jpg"]
c = []
for image in (a+b):
if image not in c:
c.append(image)
else:
c.remove(image)
print(c)