def format_lines(matched_lines, files, flags):
    """
    This formats the result of the find if the pattern is in a certain line in a file.
    If -n is in the flags the line number will be included in the search result
        `-n` Print the line numbers of each matching line.
    :param matched_lines: a list with 1 tuple containing file_name, line_number and line
    :param files: files to search for the matching pattern, will be a list
    :param flags: The flags to use for the search
    :return: a formatted search result
    :rtype: str
    """
    search_result = []

    for file_name, line_number, line in matched_lines:
        line_result = ""

        if len(files) > 1:
            line_result += file_name + ":"

        if "-n" in flags:
            line_result += str(line_number) + ":"

        line_result += line

        search_result.append(line_result)

    return "".join(search_result)