You can download this code by clicking the button below.
This code is now available for download.
The function finds a pair of numbers in a list that sum up to a given target value. If no such pair is found, it returns None.
Technology Stack : List, Dictionary
Code Type : Function
Code Difficulty : Beginner
def a_sum_pairs(numbers, target):
seen = {}
for number in numbers:
complement = target - number
if complement in seen:
return (complement, number)
seen[number] = True
return None