def format_list(data, wrap_every=3, sep=", ", newline="\n"):
    """wrap every 3 elements into a newline.
    Separate every element with specified separator"""
    if not data:
        return ""
    output = []
    for idx, el in enumerate(data):
        suffix = sep
        if (idx + 1) % wrap_every == 0:
            suffix = newline
        output.append(el)
        output.append(suffix)
    return "".join(output[0:-1])