diff --git a/friend_functions.py b/friend_functions.py index 1efb2e6..e9ff8c7 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -48,13 +48,6 @@ def people_who_like_color(people, color): return people_list def count_people_who_like_color(people, color): - """Returns the number of people who like a given color. - - >>> count_people_who_like_color(family, "red") - 2 - >>> count_people_who_like_color(family, "orange") - 1 - """ people_liking_color = people_who_like_color(people,color) people_count = 0 for person in people_liking_color: @@ -78,8 +71,15 @@ def get_color_dict(people): "orange": 1, } """ - raise NotImplementedError() - + # First, get a dictionary of all the colors that are liked. + color_dict = {} + for person in people: + for colors in person["favorite_colors"]: + color_dict[colors] = "0" + # Then, assign the correct numbers to each color. + for key in color_dict: + color_dict[key] = count_people_who_like_color(people,key) + return color_dict