I have two lists
list1 = [\'image1.png\', \'image2.png\', \'image3.png\', \'image3.png\'] list2 = [\'image1.pdf\', \'image2.eps\', \'image3.ps\']
def filename(name): return name.split('.')[0] list2_filenames = [filename(name) for name in list2] found_filenames = [name for name in list1 if filename(name) in list2_filenames]