def shift(array, default):
    """
    Shift items off the front of the `array` until it is empty, then return
    `default`.
    """
    try:
        return array.pop(0)
    except IndexError:
        return default
