I have two lists
list1 = [\'image1.png\', \'image2.png\', \'image3.png\', \'image3.png\']
list2 = [\'image1.pdf\', \'image2.eps\', \'image3.ps\']
You can try using set
to get uniques and a list comprehension to do the comparison:
from os.path import splitext
list1 = ['image1.png', 'image2.png', 'image3.png', 'image3.png']
list2 = ['image1.pdf', 'image2.eps', 'image3.ps']
reference = set([splittext(item)[0] for item in list2]) # Strip the extension
outcome = set([item for item in list1 if splittext(item)[0] in reference]) # compare
print(outcome)
>>>
{'image3.png', 'image2.png', 'image1.png'}