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

1 Expert Approved Answer
Step: 1 Unlock

import csv import os def readcontacts contacts if ospathexistscontactscsv with opencontactscsv moder ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!