You can download this code by clicking the button below.
This code is now available for download.
Calculate the sum of all different pairs from a list of integers.
Technology Stack : Built-in functions and loops
Code Type : Function
Code Difficulty :
def sum_of_pairs(numbers):
total = 0
for i in range(len(numbers)):
for j in range(i + 1, len(numbers)):
total += numbers[i] + numbers[j]
return total