diff --git a/friend_functions.py b/friend_functions.py index 4b2e665..2a3c313 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -31,13 +31,6 @@ def get_email(people, name): 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. - - >>> count_favorite_colors(family, "Tad Winters") - 2 - >>> count_favorite_colors(family, "Raphael Chambers") - 1 - """ color_count = 0 for person in people: if person["name"] == name: @@ -46,9 +39,6 @@ def count_favorite_colors(people, name): return color_count return None -print count_favorite_colors(family, "Tad Winters") -print count_favorite_colors(family, "Raphael Chambers") - def people_who_like_color(people, color): """Returns a list containing only those people who like the given color. >>> people_who_like_color(family, "yellow") @@ -67,7 +57,12 @@ def people_who_like_color(people, color): >>> people_who_like_color(family, "indigo") [] """ - raise NotImplementedError() + people_list = [] + for person in people: + for colors in person["favorite_colors"]: + if colors == color: + people_list.append(person) + return people_list def count_people_who_like_color(people, color): """Returns the number of people who like a given color.