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

This commit is contained in:
erbrown
2025-12-13 20:49:39 -05:00
parent f79959c5a4
commit 0e0962c53d
2 changed files with 11 additions and 10 deletions

View File

@@ -78,7 +78,8 @@ def count_people_who_like_color(people, color):
>>> count_people_who_like_color(family, "orange") >>> count_people_who_like_color(family, "orange")
1 1
""" """
raise NotImplementedError() return len(people_who_like_color(people, color))
def get_color_dict(people): def get_color_dict(people):
"""Returns a dict showing how many people like each color. """Returns a dict showing how many people like each color.

View File

@@ -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, "blue")), 2)
self.assertEqual(len(people_who_like_color(family, "purple")), 0) self.assertEqual(len(people_who_like_color(family, "purple")), 0)
# def test_returns_full_dicts(self): def test_returns_full_dicts(self):
# result = people_who_like_color(family, "orange") result = people_who_like_color(family, "orange")
# self.assertEqual(len(result), 1) self.assertEqual(len(result), 1)
# self.assertEqual(result[0]["email"], "auctor.odio@icloud.ca") self.assertEqual(result[0]["email"], "auctor.odio@icloud.ca")
# class TestCountPeopleWhoLikeColor(TestCase): class TestCountPeopleWhoLikeColor(TestCase):
# def test_returns_correct_count(self): def test_returns_correct_count(self):
# self.assertEqual(count_people_who_like_color(friends, "grey"), 2) 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, "beige"), 1)
# self.assertEqual(count_people_who_like_color(friends, "cornflower"), 0) self.assertEqual(count_people_who_like_color(friends, "cornflower"), 0)
# class TestGetColorDict(TestCase): # class TestGetColorDict(TestCase):
# def test_returns_correct_dict(self): # def test_returns_correct_dict(self):