Write an address book program that stores your contacts' names and their email addresses. The names and email addresses are originally stored in a file called phonebook.in, in the format: Harry Potter theboywholived@hogwarts.edu Hermione Granger brightestwitch@hogwarts.edu Ron Weasley roonilwazlib@hogwarts.edu Draco Malfoy myfatherwillhearaboutthis@hogwarts.edu Severus Snape halfbloodprince@hogwarts.edu Albus Dumbledore alasearwax@hogwarts.edu Your program should read from the file, storing the names and corresponding email addresses in a dictionary as key-value pairs. Then, the program should display a menu that lets the user enter the numbers 1 through 5, each corresponding to a different menu item: 1) look up an email address 2) add a new name and email address 3) change an email address 4) delete a name and email address 5) save address book and exit When the user enters 1, the program should prompt them for a name, and then print the corresponding email address. If there is no dictionary entry under that name, the program should print, "Sorry, no contact exists under that name." When the user enters 2, the program should prompt them for a name and an email address, then add a new key-value pair to the dictionary. When the user enters 3, the program should prompt them for a name and a new email address for that contact. It should change the value of the corresponding dictionary entry to match the new email address. When the user enters 4, the program should prompt them for a name and delete the corresponding dictionary entry. When the user enters 5, the program should write the names and email addresses in alphabetical order by first name to the file phonebook.out. Sample Run Enter↵ 1) look up an email address↵ 2) add a new name and email address↵ 3) change an email address↵ 4) delete a name and email address↵ 5) save address book and exit:1↵ Enter name:Hermione Granger↵ brightestwitch@hogwarts.edu↵ Enter↵ 1) look up an email address↵ 2) add a new name and email address↵ 3) change an email address↵ 4) delete a name and email address↵ 5) save address book and exit:5↵ ↵
Write an address book
Harry Potter
theboywholived@hogwarts.edu
Hermione Granger
brightestwitch@hogwarts.edu
Ron Weasley
roonilwazlib@hogwarts.edu
Draco Malfoy
myfatherwillhearaboutthis@hogwarts.edu
Severus Snape
halfbloodprince@hogwarts.edu
Albus Dumbledore
alasearwax@hogwarts.edu
Your program should read from the file, storing the names and corresponding email addresses in a dictionary as key-value pairs. Then, the program should display a menu that lets the user enter the numbers 1 through 5, each corresponding to a different menu item:
1) look up an email address
2) add a new name and email address
3) change an email address
4) delete a name and email address
5) save address book and exit
When the user enters 1, the program should prompt them for a name, and then print the corresponding email address. If there is no dictionary entry under that name, the program should print, "Sorry, no contact exists under that name."
When the user enters 2, the program should prompt them for a name and an email address, then add a new key-value pair to the dictionary.
When the user enters 3, the program should prompt them for a name and a new email address for that contact. It should change the value of the corresponding dictionary entry to match the new email address.
When the user enters 4, the program should prompt them for a name and delete the corresponding dictionary entry.
When the user enters 5, the program should write the names and email addresses in alphabetical order by first name to the file phonebook.out.
Sample Run
Enter↵
1) look up an email address↵
2) add a new name and email address↵
3) change an email address↵
4) delete a name and email address↵
5) save address book and exit:1↵
Enter name:Hermione Granger↵
brightestwitch@hogwarts.edu↵
Enter↵
1) look up an email address↵
2) add a new name and email address↵
3) change an email address↵
4) delete a name and email address↵
5) save address book and exit:5↵
↵
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)