def format_attribute(name, val, lng):
    """Format a string for displaying the name and value of an attribute.

    Args:
        name: name of the attribute to display.
        val: value of the attribute to display.
        lng: length of the string to be returned, in number of
        characters. Blank space will be padded with '-' characters.

    Returns: a string.
    """
    name += ' '
    if val is not None:
        val = ' ' + val
        lng -= len(val)
        return '{:-<{pad}.{trunc}}{}'.format(
            name, val, pad=lng, trunc=lng)
    else:
        return '{:<{pad}.{trunc}}'.format(name, pad=lng, trunc=lng)