diff --git a/friend_functions.py b/friend_functions.py index 93e10ec..4d88d1c 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -33,8 +33,8 @@ def get_email(people, name): for person in people: if person["name"] == name: return person["email"] - else: - return None + else: + return None def count_favorite_colors(people, name): """Returns the number of colors liked by the named person. If there is no such person, returns None. @@ -50,8 +50,8 @@ def count_favorite_colors(people, name): for color in person["favorite_colors"]: num_fav_colors = num_fav_colors + 1 return num_fav_colors - else: - return None + else: + return None def people_who_like_color(people, color): """Returns a list containing only those people who like the given color. @@ -75,7 +75,7 @@ def people_who_like_color(people, color): for person in people: if color in person["favorite_colors"]: who_likes_this_color.append(person) - return who_likes_this_color + return who_likes_this_color def count_people_who_like_color(people, color): """Returns the number of people who like a given color. @@ -108,8 +108,12 @@ def get_color_dict(people): "orange": 1, } """ - raise NotImplementedError() - + color_dict = {} + freq = 0 + for person in people: + for fav_color in person["favorite_colors"]: + color_dict[fav_color] = freq + 1 + return color_dict