You can download this code by clicking the button below.
This code is now available for download.
This function takes a list of integers as input and returns a pair of numbers if the sum of the pair is the first number in the list. If such a pair does not exist, it returns None.
Technology Stack : Dictionary (dict)
Code Type : Find function
Code Difficulty : Intermediate
def a_sum_pairs(numbers):
sum_dict = {}
for number in numbers:
if number in sum_dict:
return [sum_dict[number], number]
else:
sum_dict[number] = number
return None