generated from mwc/lab_weather
Created the first two functions where you are counting the number of people - here you use the len command to count the number of people. For the second function returned the named persons email address by using a for loop statment to help.
This commit is contained in:
@@ -17,7 +17,7 @@ def count_people(people):
|
||||
>>> count_people(friends)
|
||||
10
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
return len(people)
|
||||
|
||||
def get_email(people, name):
|
||||
"""Returns the named person's email address. If there is no such person, returns None.
|
||||
@@ -27,7 +27,11 @@ def get_email(people, name):
|
||||
>>> get_email(friends, "Tad Winters")
|
||||
None
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
for person in people:
|
||||
if name == person['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.
|
||||
|
||||
Reference in New Issue
Block a user