You can download this code by clicking the button below.
This code is now available for download.
This function is used to find two numbers in an array that add up to a target value. If such numbers are found, it returns them as a list; otherwise, it returns None.
Technology Stack : set
Code Type : Function
Code Difficulty : Intermediate
def sum_pairs(numbers, target):
seen = set()
for number in numbers:
if target - number in seen:
return [target - number, number]
seen.add(number)
return None