def announce_lead_changes(score0, score1, last_leader=None):
    """A commentary function that announces when the leader has changed.

    >>> leader, message = announce_lead_changes(5, 0)
    >>> print(message)
    Player 0 takes the lead by 5
    >>> leader, message = announce_lead_changes(5, 12, leader)
    >>> print(message)
    Player 1 takes the lead by 7
    >>> leader, message = announce_lead_changes(8, 12, leader)
    >>> print(leader, message)
    1 None
    >>> leader, message = announce_lead_changes(8, 13, leader)
    >>> leader, message = announce_lead_changes(15, 13, leader)
    >>> print(message)
    Player 0 takes the lead by 2
    """
    # BEGIN PROBLEM 6
    leader = 0
    if score0 < score1:
        leader = 1
    elif score0 > score1:
        leader = 0
    else:
        leader = None
    
    if last_leader == leader or leader == None:
        message = None
    else:
        message = 'Player ' + str(leader) + ' takes the lead by ' + str(abs(score0 - score1))
    return leader, message

    # END PROBLEM 6