code: def check_output_format(fmt, nfiles):
      
      if nfiles < 0:
          raise ValueError('Invalid file count: ' + str(nfiles))
      if nfiles == 1:
          return
      try:
          fmt % nfiles
      except TypeError as err:
          raise ValueError(''.join(
              ('Invalid file format string: ', fmt, ': ', str(err))
          ))
docs: Validate file format string.
  
      Parameters
      ----------
      fmt : `str`
          File format string.
      nfiles : `int`
          Number of files.
  
      Raises
      ------
      ValueError
          If nfiles < 0 or format string is invalid.