<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def no_counterpart_found(string, options, rc_so_far):
 """Takes action determined by options.else_action. Unless told to raise an exception, this function returns the errno that is supposed to be returned in this case. :param string: The lookup string. :param options: ArgumentParser or equivalent to provide options.else_action, options.else_errno, options.no_newline :param rc_so_far: Becomes set to the value set in options. """

    logger.debug("options.else_action: %s", options.else_action)
    if options.else_action == "passthrough":
        format_list = [string]
        output_fd = sys.stdout
    elif options.else_action == "exception":
        raise KeyError("No counterpart found for: %s" % (string))
    elif options.else_action == "error":
        format_list = ["# No counterpart found for: %s" % (string)]
        output_fd = sys.stderr
    if not options.no_newline:
        format_list.append("\n")
    output_fd.write("".join(format_list))
    return options.else_errno