generated from mwc/lab_weather
count_favorite_colors is working
I added some helper print statements at the end of friend_functions to help me test. Had an indentation error with the else statement that got me stuck for a while but is resolved now.
This commit is contained in:
parent
1631f47445
commit
e45fa894a1
|
@ -41,13 +41,24 @@ def count_favorite_colors(people, name):
|
||||||
>>> count_favorite_colors(family, "Raphael Chambers")
|
>>> count_favorite_colors(family, "Raphael Chambers")
|
||||||
1
|
1
|
||||||
"""
|
"""
|
||||||
|
'''for person in people:
|
||||||
|
if person["name"]== name:
|
||||||
|
colors = person["favorite_colors"]
|
||||||
|
return len(colors)
|
||||||
|
elif person'''
|
||||||
|
|
||||||
for person in people:
|
for person in people:
|
||||||
if person["name"]== name:
|
if person["name"]== name:
|
||||||
colors = (person["favorite_colors"])
|
colors = person["favorite_colors"]
|
||||||
return len(colors)
|
return len(colors)
|
||||||
|
else:
|
||||||
|
return "None"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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.
|
||||||
|
@ -67,7 +78,12 @@ def people_who_like_color(people, color):
|
||||||
>>> people_who_like_color(family, "indigo")
|
>>> people_who_like_color(family, "indigo")
|
||||||
[]
|
[]
|
||||||
"""
|
"""
|
||||||
raise NotImplementedError()
|
'''for person in people:
|
||||||
|
for favorite_colors, color in people.favorite_colors():
|
||||||
|
like_color = []
|
||||||
|
like_color.append(["name"])
|
||||||
|
return like_color'''
|
||||||
|
|
||||||
|
|
||||||
def count_people_who_like_color(people, color):
|
def count_people_who_like_color(people, color):
|
||||||
"""Returns the number of people who like a given color.
|
"""Returns the number of people who like a given color.
|
||||||
|
@ -100,5 +116,16 @@ def get_color_dict(people):
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
from people import friends, family
|
||||||
|
|
||||||
|
count = count_people(friends)
|
||||||
|
print("Number of freinds are", count)
|
||||||
|
|
||||||
|
email = get_email(friends, "Jelani West")
|
||||||
|
print("email is", email)
|
||||||
|
|
||||||
|
favcolor = count_favorite_colors(friends, "Yulix Reynolds")
|
||||||
|
print ("# of fav colors is", favcolor)
|
||||||
|
|
||||||
|
#like_color = people_who_like_color(family, "red")
|
||||||
|
#print("People who like red:", like_color)
|
Loading…
Reference in New Issue