How can I shorten the following MWE?
files = ['a.txt', 'b.jpg', 'c.png', 'd.JPG', 'e.JPG']
images = [x for x in files if '.jpg' in x or '.png' in x or '.JPG' in x]
print images
I was thinking in terms of
files = ['a.txt', 'b.jpg', 'c.png', 'd.JPG', 'e.JPG']
images = [x for x in files if ('.jpg' or '.png' or '.JPG') in x]
print images
which does not work.
In contrast to this post: Checking file extension, I am also interested in a generalization, which does not focus on the file ending.