From 0e0962c53d9b48859e246884f3750b585d53ad6c Mon Sep 17 00:00:00 2001 From: erbrown Date: Sat, 13 Dec 2025 20:49:39 -0500 Subject: [PATCH] for the fifth function - I used the previous function to help me code the count by using the len command that I used for the first function! Easy way to return the number of people who like a given color --- friend_functions.py | 3 ++- test_friend_functions.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/friend_functions.py b/friend_functions.py index 1d41f9d..2ca005c 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -78,7 +78,8 @@ def count_people_who_like_color(people, color): >>> count_people_who_like_color(family, "orange") 1 """ - raise NotImplementedError() + return len(people_who_like_color(people, color)) + def get_color_dict(people): """Returns a dict showing how many people like each color. diff --git a/test_friend_functions.py b/test_friend_functions.py index bf7a6cb..23a5bb8 100644 --- a/test_friend_functions.py +++ b/test_friend_functions.py @@ -44,16 +44,16 @@ class TestPeopleWhoLikeColor(TestCase): self.assertEqual(len(people_who_like_color(family, "blue")), 2) self.assertEqual(len(people_who_like_color(family, "purple")), 0) -# def test_returns_full_dicts(self): -# result = people_who_like_color(family, "orange") -# self.assertEqual(len(result), 1) -# self.assertEqual(result[0]["email"], "auctor.odio@icloud.ca") + def test_returns_full_dicts(self): + result = people_who_like_color(family, "orange") + self.assertEqual(len(result), 1) + self.assertEqual(result[0]["email"], "auctor.odio@icloud.ca") -# class TestCountPeopleWhoLikeColor(TestCase): -# def test_returns_correct_count(self): -# self.assertEqual(count_people_who_like_color(friends, "grey"), 2) -# self.assertEqual(count_people_who_like_color(friends, "beige"), 1) -# self.assertEqual(count_people_who_like_color(friends, "cornflower"), 0) +class TestCountPeopleWhoLikeColor(TestCase): + def test_returns_correct_count(self): + self.assertEqual(count_people_who_like_color(friends, "grey"), 2) + self.assertEqual(count_people_who_like_color(friends, "beige"), 1) + self.assertEqual(count_people_who_like_color(friends, "cornflower"), 0) # class TestGetColorDict(TestCase): # def test_returns_correct_dict(self):