refactor_two_sum.py

Code and working example pages keep their original identifiers and sample text. The lesson and file guidance explain them in your language.

def two_sum(numbers, target):
    d = {}
    for i, x in enumerate(numbers):
        y = target - x
        if y in d:
            return [d[y], i]
        d[x] = i
    return []