We have a list of annual rainfall recordings of cities. Each element in the list is of
Fantastic news! We've Found the answer you've been seeking!
Question:
We have a list of annual rainfall recordings of cities. Each element in the list is of the form (c,r) where c is the city and r is the annual rainfall for a particular year. The list may have multiple entries for the same city, corresponding to rainfall recordings in different years. Write a Python function rain average(l) that takes as input a list of rainfall recordings and computes the average rainfall for each city. The output should be a list of pairs (c, ar) where c is the city and ar is the average rainfall for this city among the recordings in the input list. Note that ar should be of type float. The output should be sorted in dictionary order with respect to the city name.
Related Book For
Posted Date: