"Shashwat Anand" <anand.shash...@gmail.com> wrote
list =
["something1.mp3","something2.mp3","something4.pdf","something5.odt"]
[i for i in list if i[-4:] == '.mp3']
['something1.mp3', 'something2.mp3']
Or even easier:
[s for s in list if s.endswith('.mp3')]
But for the specific case of file extensions the os.path.splitext() is
a better solution.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor