Question
Python This assignment involves the use of a dictionary, functions, and exception handling. Write a program that keeps names and email addresses in a dictionary
Python
This assignment involves the use of a dictionary, functions, and exception handling. Write a program that keeps names and email addresses in a dictionary called people as key-value pairs. The program should initialize the dictionary with three people/email addresses. Then, the program should display a menu as follows and loop until 5 is selected: Create functions and use arguments/parameters as shown in the hierarchy chart/data flow diagram below. Create each of the functions and create the main program which calls the functions. Use try/except blocks to handle the KeyError exception. Use test data as follows: o Enter a number that is not a valid selection (1-5) if invalid, give an error message o Add several names/email addresses If the name already exists, give a message and dont attempt to add it to dictionary o Look up an existing name and display associated email address Look up a name that does not exist in the dictionary and handle the exception o Change the email address associated with an existing name If the name doesnt exist, give a message and dont attempt to change it o Delete an existing name/email pair If the name doesnt exist, handle the exception Make sure to include header and step comments in your program.
1) Look up email address 2) Add a name and email address 3) Change email address 4) Delete name and email address 5) End program Enter your selection (1-5)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started