Solution Review : Average of Values of Keys in a Dictionary

This lesson will explain how to find an average of values of keys' values in a dictionary.

Solution: Use the sum() and len() function

  • Use the sum(dictionary.values()) function to calculate the sum of values in a dictionary.
  • ​Use len(dictionary) to calculate the length of dictionary, then divide the sum by length to calculate the average.

This concept is demonstrated by the following python code.

Get hands-on with 1000+ tech skills courses.