Healthy Habits

Report a typo

Anthony tracks his daily walks using an app that records the distance in meters. You are given a list of dictionaries containing his walking data for each day of the week. Write a program that calculates Anthony's average daily walking distance.

The input is a list of dictionaries called walks. Each dictionary in the list represents a day and contains two key-value pairs:

  • "day": A string with the name of the day

  • "distance": An integer representing the distance walked in meters

Example input:

walks = [
    {"day": "Monday", "distance": 2000},
    {"day": "Tuesday", "distance": 3000},
    {"day": "Wednesday", "distance": 3500},
    {"day": "Thursday", "distance": 2500},
    {"day": "Friday", "distance": 2500},
    {"day": "Saturday", "distance": 1000},
    {"day": "Sunday", "distance": 5600},
]

Your program should:

  1. Access the distance values from each dictionary in the list

  2. Calculate the mean (average) distance

  3. Use integer division to round down the result

  4. Print the final integer value

For the example input provided, the output should be: 2871.

Your solution should work for any valid input list of dictionaries following the same structure, not just the example provided. Also, don't include the example walks list into your code.

Write a program in Python 3
# the list "walks" is already defined
# your code here
___

Create a free account to access the full topic