Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to get value exists in two separate lists using python

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading