code: def replace_ext(filename, ext):
      
      if ext.startswith('.'):
          ext = ext[1:]
      stem, _ = os.path.splitext(filename)
      return (stem + '.' + ext)
docs: Return new pathname formed by replacing extension in `filename` with `ext`.