import os source = ['test_sound.flac','ts.mp3'] for files in source: fileName,fileExtension = os.path.splitext(files) print fileExtension # Print File Extensions print fileName # It print file name