def inc_avg(li):
    """
    Calculate the average incrementally.
    Input: a list.
    Output: average of the list.
    See http://ubuntuincident.wordpress.com/2012/04/25/calculating-the-average-incrementally/ .

    >>> inc_avg([2, 3, 4])
    3.0
    """
    left = 0
    right = len(li) - 1

    avg = li[left]
    left += 1

    while left <= right:
        curr = left + 1
        avg += (li[left] - avg) / float(curr)
        left += 1

    return avg