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 returns a list containing the sums of all different pairs of numbers.
Technology Stack : List comprehension, function, comparison operator
Code Type : List Derivation and Functions
Code Difficulty : Intermediate
def sum_of_pairs(numbers):
def sum_pairs(a, b):
return a + b
return [sum_pairs(num1, num2) for num1 in numbers for num2 in numbers if num1 != num2]