generated from mwc/lab_weather
Created a function that returned a list so we had to start out with result to = [] and then work throught the dictionary to get the final output. Used the append command that was used in the scatter lab to create the list! created a for statement to help get the information we needed!
This commit is contained in:
@@ -64,7 +64,11 @@ def people_who_like_color(people, color):
|
||||
>>> people_who_like_color(family, "indigo")
|
||||
[]
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
result = []
|
||||
for person in people:
|
||||
if color in person["favorite_colors"]:
|
||||
result.append(person)
|
||||
return result
|
||||
|
||||
def count_people_who_like_color(people, color):
|
||||
"""Returns the number of people who like a given color.
|
||||
|
||||
@@ -30,19 +30,19 @@ from friend_functions import (
|
||||
# def test_returns_none_when_person_missing(self):
|
||||
# self.assertEqual(get_email(family, "Ken Kesey"), None)
|
||||
|
||||
class TestCountFavoriteColors(TestCase):
|
||||
def test_returns_len_favorite_colors_when_person_found(self):
|
||||
self.assertEqual(count_favorite_colors(family, "Tad Winters"), 2)
|
||||
self.assertEqual(count_favorite_colors(friends,"Connor Rodriguez"), 4)
|
||||
self.assertEqual(count_favorite_colors(friends, "Yuli Reynolds"), 0)
|
||||
# class TestCountFavoriteColors(TestCase):
|
||||
# def test_returns_len_favorite_colors_when_person_found(self):
|
||||
# self.assertEqual(count_favorite_colors(family, "Tad Winters"), 2)
|
||||
# self.assertEqual(count_favorite_colors(friends,"Connor Rodriguez"), 4)
|
||||
# self.assertEqual(count_favorite_colors(friends, "Yuli Reynolds"), 0)
|
||||
|
||||
def test_returns_none_when_person_missing(self):
|
||||
self.assertEqual(count_favorite_colors(family, "Ken Kesey"), None)
|
||||
# def test_returns_none_when_person_missing(self):
|
||||
# self.assertEqual(count_favorite_colors(family, "Ken Kesey"), None)
|
||||
|
||||
# class TestPeopleWhoLikeColor(TestCase):
|
||||
# def test_returns_correct_length(self):
|
||||
# self.assertEqual(len(people_who_like_color(family, "blue")), 2)
|
||||
# self.assertEqual(len(people_who_like_color(family, "purple")), 0)
|
||||
class TestPeopleWhoLikeColor(TestCase):
|
||||
def test_returns_correct_length(self):
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user