def format_priv_text(values, max_char):
    """Formats privileged (or unprivileged) values text
    so that it can be shown.

    Parameters
    ----------
    values: list
        List of privileged or unprivileged values
    max_char: int
        Maximum characters allow in the returned string

    Returns
    -------
    str:
        Formated string for given values

    Raises
    ------
    TypeError
        values must be a list
    """
    if type(values) != list:
        raise TypeError('values must be a list')

    priv_text = ''

    for val in values:
        if (len(val) + len(priv_text) > max_char) & (priv_text != ''):
            priv_text = priv_text[:-2] + ' and others  '
            break
        priv_text += val+', '

    return priv_text[:-2]