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