From 5aa2e0256d1c2eed9d010694e1aa92fdb8834133 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 14 Oct 2024 17:04:23 -0400 Subject: [PATCH] I got the get_color_dict to "work" but only if the maximum number of times a favorite color is listed is two. I tried to update the dictionary entries using a frequency variable, but it wasn't working, so I wrote it so that it just entered either 1 or 2. --- friend_functions.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/friend_functions.py b/friend_functions.py index 4d88d1c..417e73d 100644 --- a/friend_functions.py +++ b/friend_functions.py @@ -109,12 +109,10 @@ def get_color_dict(people): } """ color_dict = {} - freq = 0 for person in people: for fav_color in person["favorite_colors"]: - color_dict[fav_color] = freq + 1 + if fav_color in color_dict: + color_dict[fav_color] = 2 + else: + color_dict[fav_color] = 1 return color_dict - - - -