Question
Your instructor should provide a CSV file named contacts.csv. When the program starts, it should read the contacts from the CSV file. For
Your instructor should provide a CSV file named contacts.csv.
When the program starts, it should read the contacts from the CSV file.
For the view and del commands, display an error message if the user enters an invalid contact number.
When you add or delete a contact, the change should be saved to the CSV file immediately.
That way, no changes are lost, even if the program crashes later.
COMMAND MENU
list - Display all contacts
view - View a contact
add - Add a contact
del - Delete a contact
exit - Exit program
Command: list
1. Guido van Rossum
2. Eric Idle
Command: view
Number: 2
Name: Eric Idle
Email: e..c@ericidle.com
Phone: +44 20 7946 0958
Command: add
Name: Mike Murach
Email: m..e@murach.com
Phone: 559-123-4567
Mike Murach was added.
Command: list
1. Guido van Rossum
2. Eric Idle
3. Mike Murach
Command: exit
Bye!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
import csv import os def readcontacts contacts if ospathexistscontactscsv with opencontactscsv moder ...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