import re


def insertAttribute(tag, attribute, newValue):
    """
    Inserts the specified attribute in the specified tag, with the value
    newValue.
    (The attribute is inserted as the last attribute in the tag).
    """

    value = re.sub(r'([/])>', '\n    ' + attribute + '="' + newValue
                   + '" \1>\n    ', tag[1])
    tag[1] = value

    return tag