From 2dc845fd63edf4ad0c9b0b5e48df0ad71f9e7f36 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 13 Oct 2024 22:17:38 -0400 Subject: [PATCH] I got the count_people_who_like_color function to work. I was trying to check if a color was in the list using if person["favorite_colors"] == color but then I figured that if it was just one color in a list of colors it wouldn't work. --- friend_functions.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/friend_functions.py b/friend_functions.py index b001762..c4d1fe7 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -72,7 +72,7 @@ def people_who_like_color(people, color): [] """ raise NotImplementedError() - + def count_people_who_like_color(people, color): """Returns the number of people who like a given color. @@ -81,7 +81,11 @@ def count_people_who_like_color(people, color): >>> count_people_who_like_color(family, "orange") 1 """ - raise NotImplementedError() + how_many_like_color = 0 + for person in people: + if color in person["favorite_colors"]: + how_many_like_color = how_many_like_color + 1 + return how_many_like_color def get_color_dict(people): """Returns a dict showing how many people like each color.