From e45fa894a1b376c48580298f3543d24fb5b3548d Mon Sep 17 00:00:00 2001 From: Chris Mekelburg Date: Sun, 13 Oct 2024 22:07:02 -0400 Subject: [PATCH] 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. --- friend_functions.py | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/friend_functions.py b/friend_functions.py index 1e7535b..cb4aa90 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -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) \ No newline at end of file