generated from mwc/lab_weather
1 commit 5: Wrote count_people_who_like_color
I didn't get stuck on this one :D
This commit is contained in:
parent
ffb18b847b
commit
ed792e58ee
|
@ -40,23 +40,6 @@ def count_favorite_colors(people, name):
|
|||
return None
|
||||
|
||||
def people_who_like_color(people, color):
|
||||
"""Returns a list containing only those people who like the given color.
|
||||
>>> people_who_like_color(family, "yellow")
|
||||
[
|
||||
{
|
||||
"name": "Walker Hurley",
|
||||
"email": "auctor.odio@icloud.ca",
|
||||
"favorite_colors": ["red", "yellow", "blue", "orange"],
|
||||
},
|
||||
{
|
||||
"name": "Clementine Joseph",
|
||||
"email": "hendrerit@aol.co.uk",
|
||||
"favorite_colors": ["yellow", "aqua", "black"],
|
||||
}
|
||||
]
|
||||
>>> people_who_like_color(family, "indigo")
|
||||
[]
|
||||
"""
|
||||
people_list = []
|
||||
for person in people:
|
||||
for colors in person["favorite_colors"]:
|
||||
|
@ -72,7 +55,11 @@ def count_people_who_like_color(people, color):
|
|||
>>> count_people_who_like_color(family, "orange")
|
||||
1
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
people_liking_color = people_who_like_color(people,color)
|
||||
people_count = 0
|
||||
for person in people_liking_color:
|
||||
people_count = people_count + 1
|
||||
return people_count
|
||||
|
||||
def get_color_dict(people):
|
||||
"""Returns a dict showing how many people like each color.
|
||||
|
|
Loading…
Reference in New Issue