Question: to practice iterating over nested compound data and accessing different dictionary fields Degree of Difficulty: Easy. Write a function called ward_neighbourhood_schools() which takes as parameter(s):
to practice iterating over nested compound data and accessing different dictionary fields Degree of Difficulty: Easy. Write a function called ward_neighbourhood_schools() which takes as parameter(s): A dictionary in the format of the city database as described in Q1 The name of a ward, as a string The function should construct and return a list containing the neighbourhoods that can be found in a particular ward and the number of schools in these neighbourhoods. For example, for the input file you were given, if the ward is "Ward 2", the resulting list should be (though not necessarily in this order). t [( Meadowgreen ,0), ( Westmount ,1), ( Pleasant Hill ,2), ( Caswell Hill ,1), ( Montgomery Place ,1), ( King George ,1), ( Holiday Park ,2), ( Riversdale ,0)] \.. Note, items in the above list are tuples. Recall, a tuple is like a list except that tuples are immutable. Also, note that this function must not change the city database in any way.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
