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.
This commit is contained in:
root 2024-10-14 17:04:23 -04:00
parent 010dd82161
commit 5aa2e0256d
1 changed files with 4 additions and 6 deletions

View File

@ -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