Is there a function to extract the extension from a filename?
filename='ext.tar.gz' extension = filename[filename.rfind('.'):]