A pair that hits the target
You have a list of numbers and a target. Find two different positions whose values add up to the target.
pair_with_sum([4, 7, 1, 5], 6) # (2, 3)
pair_with_sum([3], 6) # NoneIf several pairs work, return the one that finishes earliest, meaning the smallest second index. If several first indexes work with that second index, take the smallest.
Approach
Trying all pairs is quadratic. Instead, walk the list once and ask, for each value, whether its complement has already appeared:
need = target - value
if need in seen:
...Store each value's first index in a dict as you go. Check before you store, so a value cannot pair with itself. Stopping at the first hit gives the earliest finish automatically.
Your task
Write pair_with_sum(numbers, target) returning (i, j) with i < j as described, or None if no pair adds up to the target.
The explanation opens here once every check passes.