def remove_file_type(infile): import re return(re.sub('\.[^.]*$','',infile)) remove_file_type('abc.efg')'abc'