generated from mwc/lab_weather
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.
This commit is contained in:
parent
a82e20884f
commit
2dc845fd63
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue