Question: In this assignment, you will implement a program in python to help user manage their contacts using a dictionary of dictionaries. The program should use
In this assignment, you will implement a program in python to help user manage their contacts using a dictionary of dictionaries.
The program should use a dictionary of dictionaries to store the contacts info where the key of the outer dictionary is the contact name and the key of the nested directory is the field name. Use the starter file contactsManager-starter.py where the dictionary of dictionaries is created for you at the beginning of the main function. Complete the starter file by implementing the contacts manager. Specifically, write a program that 1. Welcomes the user 2. Prints the available commands: COMMAND MENU list - Display all contacts (Displays an alphabetically sorted list of the names of all the players.) view - View a contact (this will first prompt the user for the name of the contact user wants to view, then check if the name exists in the contacts, if so, prints all the fields for that contact in alphabetically sorted fashion. If the name is not found in the dictionary, prints No contact found for that name. See sample runs below.) add - Add a contact (this will prompt the user for the contact name, phone, company and address fields and create a new entry in the dictionary for that name. See sample runs below.) del - Delete a contact (this will prompt the user for the name of the contact to be deleted and then delete the corresponding contact from the dictionary) field View field for all (this will prompt the user for the name of the field to be viewed. Check that there is at least one contact with that field. If so, prints the field for all the contacts with that field specified. Otherwise prints Field not found in any contact See sample runs below.)exit - Exit program 3. Then repeatedly prompts the user to enter the command and acts on the command as per the specification above. Program handles the case of user entering an invalid command. 4. When user enters exit command, program ends.
ContactManager: Requirements
1. The program shouldnt assume that the dictionary was created with alphabetically sorted key values or alphabetically sorted fields. The program should work with any data correctly. 2. Define functions for each of the commands (except for the exit command) that takes a dictionary of dictionaries containing the contacts data as an argument and acts on the command correctly. 3. Make sure you handle boundary cases: a. Invalid command: print Invalid command and prompt again for the next command b. Contact data is empty: list command should print No contacts to show. If the contacts data is empty. c. Name not found in the contacts data: both the view and del commands should print No contact found for that name. d. Field not found: field command should print No contact found with that field if none of the contacts in the data has that field specified.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
