generated from mwc/lab_weather
	friend_functions.py
This commit is contained in:
		@@ -20,22 +20,23 @@
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
def get_email(people, name):
 | 
			
		||||
    """Returns the named person's email address. If there is no such person, returns None.
 | 
			
		||||
# 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
 | 
			
		||||
    """
 | 
			
		||||
#         >>> get_email(family, "Tad Winters")
 | 
			
		||||
#         "ligula.aenean@hotmail.edu"
 | 
			
		||||
#         >>> get_email(friends, "Tad Winters")
 | 
			
		||||
#         None
 | 
			
		||||
#     """
 | 
			
		||||
 | 
			
		||||
    for person in people:
 | 
			
		||||
        if (person["name"]==name):
 | 
			
		||||
            return person["email"]
 | 
			
		||||
#     for person in people:
 | 
			
		||||
#         if (person["name"]==name): # on the left is the syntax 
 | 
			
		||||
#             # for a dict within a list lookup
 | 
			
		||||
#             return person["email"] # dict within a list lookup
 | 
			
		||||
           
 | 
			
		||||
    return None
 | 
			
		||||
#     return None # reached the end of the list without a match
 | 
			
		||||
 | 
			
		||||
#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.
 | 
			
		||||
 | 
			
		||||
        >>> count_favorite_colors(family, "Tad Winters")
 | 
			
		||||
@@ -43,7 +44,12 @@ def get_email(people, name):
 | 
			
		||||
        >>> count_favorite_colors(family, "Raphael Chambers")
 | 
			
		||||
        1
 | 
			
		||||
    """
 | 
			
		||||
#   raise NotImplementedError()
 | 
			
		||||
    for person in people:
 | 
			
		||||
        if (person["name"]==name): # for a dict within a list lookup
 | 
			
		||||
            return len(person["favorite_colors"]) # count of list elements in a dict within a list
 | 
			
		||||
        
 | 
			
		||||
    return None # reached the end of the list without a match
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#def people_who_like_color(people, color):
 | 
			
		||||
    """Returns a list containing only those people who like the given color.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user