Insert position

Write insert_position(items, target) that returns the index at which target should be inserted into the sorted list items to keep it sorted. If target is already present, return the index of its first occurrence. This is what bisect.bisect_left does; write it yourself.

insert_position([1, 3, 5, 7], 4)  ->  2
insert_position([1, 3, 5, 7], 5)  ->  2
insert_position([1, 3, 5, 7], 9)  ->  4
insert_position([], 9)            ->  0

The point is to practise binary search for a boundary rather than a match: the answer is the first index whose item is at least target.

def insert_position(items, target):
    ...