Average Age

Python for AIMedium+10 XP+10

Average Age

Write average_age(people) that returns the average of the "age" values in a list of person dictionaries.

  • Return the plain result of dividing. Don't round it.
  • An empty list gives 0.

Examples

people = [{'name': 'ada', 'age': 30}, {'name': 'bo', 'age': 41}]
returns 35.5
people = [{"name": "ada", "age": 36}, {"name": "grace", "age": 45}, {"name": "linus", "age": 28}]
returns 36.333333333333336
people = []
returns 0

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run