Question: Once you tested your function for a single list, you can re - use it to solve the original problem. This time you are given

Once you tested your function for a single list, you can re-use it to solve the original problem. This time you are given a people list of non-empty lists, where each list represents different bridges and a number of people crossed it. You are also given a list of names of the bridges corresponding to the list of people. Write a function that outputs a name of the bridge with the highest average (as described above). You can assume that the lengths of both lists are the same. Special instructions: If there is a tie, return the highest average that appears first. In case of an empty list, return No bridges to choose from. If all the bridges have average rating 0.0, treat 0.0 as the best rating and return the first route. Hints: You should reuse the function from Question 4.1 max() will be helpful The lists .index() might be helpful (look up the documentation!) The function should work with any number of bridges. def best_average_bridge(people, bridges): """ Finds the best bridge name based on the average --->>> ratings =[[1,10,5],[4,6,9]]>>> names =["flames", "river"]>>> best_average_bridge(ratings, names) 'river' >>> ratings =[[6,10,5,3,8],[10,10,9],[6,6,90]]>>> names =["flames", "flower", "river"]>>> best_average_bridge(ratings, names) 'flower' >>> ratings =[[],[],[]]>>> names =["flames", "flower", "river"]>>> best_average_bridge(ratings, names) 'flames' >>> best_average_bridge([],[])'No bridges to choose from' """

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!