diff --git a/friend_functions.py b/friend_functions.py index d64b0d6..4b2e665 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -28,6 +28,7 @@ def get_email(people, name): for person in people: if person["name"] == name: return person["email"] + 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. @@ -37,7 +38,16 @@ def count_favorite_colors(people, name): >>> count_favorite_colors(family, "Raphael Chambers") 1 """ - raise NotImplementedError() + color_count = 0 + for person in people: + if person["name"] == name: + for colors in person["favorite_colors"]: + color_count = color_count + 1 + 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. diff --git a/friend_functions.pyc b/friend_functions.pyc index 8704c09..e0456d3 100644 Binary files a/friend_functions.pyc and b/friend_functions.pyc differ