def generate_previous_list(next_list):
    """
    Generate the expected list of previous values given a list of next values.
    Lags the next list, holds the last valid number, and adds None to the
    front. e.g.
    [0,1,2,None,None,None] -> [None, 0,1,2,2,2]
    """
    # Add none and lag the list
    previous_list = [None] + next_list[:-1]

    # Hold the last valid number by replacing None with last valid number
    idx_last_valid = 1
    for i in range(1, len(previous_list)):
        if previous_list[i] is None:
            previous_list[i] = previous_list[idx_last_valid]
        else:
            idx_last_valid = i

    assert len(next_list) == len(previous_list)
    return previous_list