Checkpoint 1 commit 2: Wrote get_email.

I got stuck with this in a couple places. The first was just getting
used to the syntax. The second was that I wasn't sure of the
difference between is and ==. Similar to before, I just tested
the specific function in friend_functions.py using the test cases
given and checked what output I was actually getting to figure out
what it was doing, which wasn't always obvious when running
test_friend_functions.py
This commit is contained in:
Cory Dean Chung 2023-08-14 14:10:04 -04:00
parent fe0c595b4b
commit dc696ef25a
2 changed files with 5 additions and 8 deletions

View File

@ -9,6 +9,8 @@
# Your job is to complete these functions. Remove the NotImplementedError from
# each and instead write code which returns the expected values.
from people import friends, family
def count_people(people):
"""Counts the number of people.
@ -23,14 +25,9 @@ def count_people(people):
return counted
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")
"ligula.aenean@hotmail.edu"
>>> get_email(friends, "Tad Winters")
None
"""
raise NotImplementedError()
for person in people:
if person["name"] == name:
return person["email"]
def count_favorite_colors(people, name):
"""Returns the number of colors liked by the named person. If there is no such person, returns None.

Binary file not shown.