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:
Chris Mekelburg 2024-10-13 22:07:02 -04:00
parent 1631f47445
commit e45fa894a1
1 changed files with 31 additions and 4 deletions

View File

@ -41,13 +41,24 @@ def count_favorite_colors(people, name):
>>> count_favorite_colors(family, "Raphael Chambers")
1
"""
'''for person in people:
if person["name"]== name:
colors = person["favorite_colors"]
return len(colors)
elif person'''
for person in people:
if person["name"]== name:
colors = (person["favorite_colors"])
colors = person["favorite_colors"]
return len(colors)
else:
return "None"
else:
return "None"
def people_who_like_color(people, 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")
[]
"""
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):
"""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)