code: def extension(filename):
      '''Properly extract the extension from filename'''
      filename = os.path.basename(filename)
      extension = None
  
      while '.' in filename:
          filename, ext = os.path.splitext(filename)
          if ext.startswith('.'):
              ext = ext[1:]
          extension = ext if not extension else ext + '.' + extension
  
      return extensiof extension(filename):
      '''Properly extract the extension from filename'''
      filename = os.path.basename(filename)
      extension = None
  
      while '.' in filename:
          filename, ext = os.path.splitext(filename)
          if ext.startswith('.'):
              ext = ext[1:]
          extension = ext if not extension else ext + '.' + extension
  
      return extension
docs: Properly extract the extension from filename