generated from mwc/lab_weather
I got the count_favorite_colors function to work.
Still using list iteration, not sure if I should be...
This commit is contained in:
parent
9bc09ed4db
commit
a82e20884f
|
@ -44,7 +44,14 @@ def count_favorite_colors(people, name):
|
||||||
>>> count_favorite_colors(family, "Raphael Chambers")
|
>>> count_favorite_colors(family, "Raphael Chambers")
|
||||||
1
|
1
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
num_fave_colors = 0
|
||||||
|
for person in people:
|
||||||
|
if person["name"] == name:
|
||||||
|
for color in person["favorite_colors"]:
|
||||||
|
num_fav_colors = num_fav_colors + 1
|
||||||
|
return num_fav_colors
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def people_who_like_color(people, color):
|
def people_who_like_color(people, color):
|
||||||
"""Returns a list containing only those people who like the given color.
|
"""Returns a list containing only those people who like the given color.
|
||||||
|
|
Loading…
Reference in New Issue