# friend_functions.py # ------------ # By MWC Contributors # # Each of the functions below expects a list of dictionaries as its first # argument. Two examples of the expected input are provided in people.family # and people.friends. # Your job is to complete these functions. Remove the NotImplementedError from # each and instead write code which returns the expected values. def count_people(people): return len(people) def get_email(people, name): for person in people: if person["name"] == name: return person["email"] return None def count_favorite_colors(people, name): for person in people: if person["name"] == name: return len(person["favorite_colors"]) return None def people_who_like_color(people, color): return [person for person in people if color in person["favorite_colors"]] def count_people_who_like_color(people, color): return len(people_who_like_color(people, color)) def get_color_dict(people): color_dict = {} for person in people: for color in person["favorite_colors"]: color_dict[color] = color_dict.get(color,0) + 1 return color_dict