def index_of_closest_element(ascending_list, datum):
    """Return index of the list element whose value is closest to datum."""
    old_delta = abs(ascending_list[0] - datum)
    for index, element in enumerate(ascending_list[1:]):
        delta = abs(element - datum)
        if delta > old_delta:
            return index
        old_delta = delta
    return len(ascending_list) - 1