Shortest window with enough

nums is a list of positive whole numbers. Write shortest_window(nums, target) that returns the length of the shortest run of consecutive items whose sum is at least target, or 0 if no run reaches it.

shortest_window([2, 3, 1, 2, 4, 3], 7)  ->  2     (4 + 3)
shortest_window([1, 1, 1], 5)           ->  0
shortest_window([5], 5)                 ->  1

The point is to practise a variable-size sliding window: grow the right end until the sum is enough, then shrink from the left while it still is.

def shortest_window(nums, target):
    ...