def find_last(arr, val):
    """ Index of the last occurence of val in arr.
    """
    i = len(arr) - 1
    while i > 0:
        if val == arr[i]:
            return i
        i -= 1
    raise Exception('val not found in arr')