Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Built-in Functions Common to Most Data Structures
5. sum()
Summary

Instruction

Great! Another important built-in function is sum(). It works with data structures that only contain numbers. Here, it is finding the total number of requests processed:

requests_processed = [12, 18, 15, 23, 24, 8, 0, 18, 14, 13]
sum(requests_processed) # result: 145

If you want to use sum on dictionary values, you can do that too. Just remember to specify that the function should use the values rather than the keys:

requests_processed = {1:12, 2:18, 3:15, 4:23, 5:24, 6:8, 7:0, 8:18, 9:14, 10:13}
sum(requests_processed.values()) # result: 145

Exercise

Write a function named get_greatest_sum(set1, set2, set3) that accepts three sets of numbers and returns the greatest sum of the sets' elements.

Stuck? Here's a hint!

Combine the sum() and max() functions to get the answer.