The load_contact_list Function You will first implement the load_contact_list function, which should take in one argument, the name of the file to load. This function should read the contact list file...


Implement the following functions:


- code should be in python


The load_contact_list Function<br>You will first implement the load_contact_list function, which should take in one argument, the name of the file to load.<br>This function should read the contact list file that is passed in, store the contents into a dictionary of dictionaries, and<br>return that dictionary.<br>• The higher-level dictionary should contain the names as its keys.<br>• Each entry in the higher-level dictionary should contain 3 entries with the keys email, phone, and address. The values<br>for each of these dictionaries should be filled according the content loaded from the lists.<br>For example, consider the sample file containing the following few lines:<br>Sandy Cheeks, cheeks@ucsc.edu, 831-507-8282, 157 Dome Drive<br>Perry Platypus, notaplatypus@ucsc.edu, 510-339-2102, 7211 Tristate Alley<br>Ino Yamanaka, telekineticflower@ucsc.edu, 415-988-2341, 98 Konoha Lane<br>The following code should produce the following results (displayed output is italicized).<br>contact_list_dict = load_contact_list('sample_contact_list.txt')<br>print(contact_list_dict['Sandy Cheeks'])<br>{'email': 'cheeks@ucsc. edu', 'phone': '831-507-8282',<br>print(contact_list_dict['Ino Yamanaka']['email']<br>telekineticflower@ucsc. edu<br>'address': '157 Dome Drive'}<br>Keep in mind that content values must be trimmed of surrounding whitespaces.<br>

Extracted text: The load_contact_list Function You will first implement the load_contact_list function, which should take in one argument, the name of the file to load. This function should read the contact list file that is passed in, store the contents into a dictionary of dictionaries, and return that dictionary. • The higher-level dictionary should contain the names as its keys. • Each entry in the higher-level dictionary should contain 3 entries with the keys email, phone, and address. The values for each of these dictionaries should be filled according the content loaded from the lists. For example, consider the sample file containing the following few lines: Sandy Cheeks, [email protected], 831-507-8282, 157 Dome Drive Perry Platypus, [email protected], 510-339-2102, 7211 Tristate Alley Ino Yamanaka, [email protected], 415-988-2341, 98 Konoha Lane The following code should produce the following results (displayed output is italicized). contact_list_dict = load_contact_list('sample_contact_list.txt') print(contact_list_dict['Sandy Cheeks']) {'email': 'cheeks@ucsc. edu', 'phone': '831-507-8282', print(contact_list_dict['Ino Yamanaka']['email'] telekineticflower@ucsc. edu 'address': '157 Dome Drive'} Keep in mind that content values must be trimmed of surrounding whitespaces.
Helper Functions<br>You will also implement the following helper functions that use the dictionary returned from the load_contact_list<br>function you implement. The first argument of each of these functions will be the contact list dictionary. This is<br>necessary so these helper functions have the dictionary in their scope.<br>• get_email: The second argument is a name. This function returns the email of the specified contact. If contact is not<br>found, this function must print an error and return None.<br>• get_phone: The second argument is a name. This function returns the phone number for the specified contact. If<br>contact is not found, this function must print an error and return None.<br>get_address: The second argument is a name. This function returns the address for the specified contact. If contact<br>is not found, this function must print an error and return None.<br>get_email_list: The second argument is a list of names. This function returns a list of emails for all specified contacts.<br>If one of the contacts is not found, this function must print an error message (that includes the name of the contact<br>not found) and not include a value for that missing contact in the list that is returned.<br>• get_phone_list: The second argument is a list of names. This function returns a list of phone numbers for all<br>specified contacts. If one of the contacts is not found, this function must print an error message (that includes the<br>name of the contact not found) and not include a value for that missing contact in the list that is returned.<br>get_address_list: The second argument is a list of names. This function returns a list of addresses for all specified<br>contacts. If one of the contacts is not found, this function must print an error message (that includes the name of<br>the contact not found) and not include a value for that missing contact in the list that is returned.<br>Requirements<br>1. Your program must implement all the functions (load_contact_list and the helper functions) listed above. Your<br>implemented functions must have the same name as the descriptions above, or you will lose points.<br>2. Each function you implement must follow the descriptions provided above.<br>

Extracted text: Helper Functions You will also implement the following helper functions that use the dictionary returned from the load_contact_list function you implement. The first argument of each of these functions will be the contact list dictionary. This is necessary so these helper functions have the dictionary in their scope. • get_email: The second argument is a name. This function returns the email of the specified contact. If contact is not found, this function must print an error and return None. • get_phone: The second argument is a name. This function returns the phone number for the specified contact. If contact is not found, this function must print an error and return None. get_address: The second argument is a name. This function returns the address for the specified contact. If contact is not found, this function must print an error and return None. get_email_list: The second argument is a list of names. This function returns a list of emails for all specified contacts. If one of the contacts is not found, this function must print an error message (that includes the name of the contact not found) and not include a value for that missing contact in the list that is returned. • get_phone_list: The second argument is a list of names. This function returns a list of phone numbers for all specified contacts. If one of the contacts is not found, this function must print an error message (that includes the name of the contact not found) and not include a value for that missing contact in the list that is returned. get_address_list: The second argument is a list of names. This function returns a list of addresses for all specified contacts. If one of the contacts is not found, this function must print an error message (that includes the name of the contact not found) and not include a value for that missing contact in the list that is returned. Requirements 1. Your program must implement all the functions (load_contact_list and the helper functions) listed above. Your implemented functions must have the same name as the descriptions above, or you will lose points. 2. Each function you implement must follow the descriptions provided above.
Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here