friend_functions.py

This commit is contained in:
njmason2
2025-10-17 16:02:14 -04:00
parent 892ffc36f4
commit 7f9e9bfb2a
3 changed files with 76 additions and 71 deletions

View File

@@ -9,18 +9,18 @@
# Your job is to complete these functions. Remove the NotImplementedError from
# each and instead write code which returns the expected values.
def count_people(people):
"""
>>> count_people(family)
5
>>> count_people(friends)
10
"""
return len(people)
# def count_people(people):
# """
# >>> count_people(family)
# 5
# >>> count_people(friends)
# 10
# """
# return len(people)
#def get_email(people, name):
def get_email(people, name):
"""Returns the named person's email address. If there is no such person, returns None.
>>> get_email(family, "Tad Winters")
@@ -28,7 +28,12 @@ def count_people(people):
>>> get_email(friends, "Tad Winters")
None
"""
# raise NotImplementedError()
for person in people:
if (person["name"]==name):
return person["email"]
return None
#def count_favorite_colors(people, name):
"""Returns the number of colors liked by the named person. If there is no such person, returns None.