def surround_with_header(string, width, char='-'):
    """
    Surround the string by a header.  The result has length min(len(string)+2, width)
    :param string: A string
    :param width: Width of the entire header
    :param char: Character to repeat
    :return: A header, whose length will be
    """
    left = (width - len(string) - 1) // 2
    right = (width - len(string) - 2) // 2
    return char * left + ' ' + string + ' ' + char * right
