You can download this code by clicking the button below.
This code is now available for download.
This function takes a list of numbers and a target sum as input, and returns a pair of numbers from the list whose sum equals the target sum. If no such pair is found, it returns None.
Technology Stack : set
Code Type : Function
Code Difficulty : Intermediate
def sum_pairs(numbers, target_sum):
seen = set()
for number in numbers:
if target_sum - number in seen:
return (target_sum - number, number)
seen.add(number)
return None