Last occurrence

Write last_occurrence(items, target) that returns the index of the last target in a sorted list that may contain repeats, or -1 if it is absent.

last_occurrence([1, 2, 2, 2, 3, 5], 2)  ->  3
last_occurrence([1, 2, 2, 2, 3, 5], 4)  ->  -1

The point is to practise binary search that keeps going right after a match.

def last_occurrence(items, target):
    ...