generated from mwc/lab_weather
count_people_who_like_color is working
I think I got this function working, but it's difficult to decipher the error messages in the test_friend_functions program. I'm going to attempt the last function and then revisit anything that is still giving an error.
This commit is contained in:
parent
36bee1bf5f
commit
f9ec3295a6
|
@ -83,7 +83,11 @@ 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()
|
like_color2 = []
|
||||||
|
for person in people:
|
||||||
|
if color in person["favorite_colors"]:
|
||||||
|
like_color2.append(person["name"])
|
||||||
|
return len(like_color2)
|
||||||
|
|
||||||
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.
|
||||||
|
@ -118,4 +122,7 @@ favcolor = count_favorite_colors(friends, "Yulix Reynolds")
|
||||||
print ("# of fav colors is", favcolor)
|
print ("# of fav colors is", favcolor)
|
||||||
|
|
||||||
like_color = people_who_like_color(family, "aqua")
|
like_color = people_who_like_color(family, "aqua")
|
||||||
print("People who like red:", like_color)
|
print("People who like red:", like_color)
|
||||||
|
|
||||||
|
count_color = count_people_who_like_color(friends, "red")
|
||||||
|
print("# who like red:", count_color)
|
Loading…
Reference in New Issue