Question
Open the data file and load the json data into the variable crime_list. You will need to reduce crime_list into three dictionaries: murder_by_region, violent_by_region, and
Open the data file and load the json data into the variable crime_list.
You will need to reduce crime_list into three dictionaries: murder_by_region, violent_by_region, and nonviolent_by_region. for each of the three dictionaries, iterate over crime_list and creating the appropriate dictionary using an accumulation pattern. Print the resultant dictionaries. The contents should be identical to that shown below. Note, to produce the three above dictionaries, approach using three functions accum_crime, accum_violent_crime, and accum_nonviolent_crime. The function accum_crime has three parameters: key: The entity upon which I'm accumulating "Region" or "State". crime: The crime on which I'm accumulating, e.g., "Murder" crime_list: The list containing dictionaries for each city. Once the working accum_crime function which produced the murder dictionary, copy that function as the accum_violent_crime, removed the crime parameter, and made the appropriate changes to the measurement to accumulate violent crimes. Once this function was working, copy as accum_nonviolent_crime function and made the appropriate changes to the measurement.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started