<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def check_output_format(fmt, nfiles):
 """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. """

    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))
        ))