Question: In this assignment, you will implement a very simple contact organizer application in python. You will write a program called contacts.py. Using this application, you

In this assignment, you will implement a very simple contact organizer application in python. You will write a program called contacts.py. Using this application, you will be able to request contact information, as well as add new contacts to your list. This program will read and write contacts to/from a file named contacts.txt. contacts.txt will have a file format that looks like the following:

Bill Jones | bjong-mail.com | 520-999-8765 Sam Dekker | dekkerapple.com | 123-456-7890 Janet Keller | kelyahoo.com | 456-2356 James Jamie | jjamieg-mail.com | 435-234-2334 

The precise names, emails, and phone numbers may vary. Also, the number of contacts in the file may vary. You should not assume that the file has any particular number of contacts in it. It could even be totally empty. You can assume that the contacts.txt file is in the same directory as the program you are implementing (contacts.py). When contacts.py begins, it should read in and save all of the contact names, emails, and phone numbers into the program. Since you wont know how many contacts are in the file ahead-of-time, you should use lists to accomplish store the information in. As you read in each contact, you can append the info into lists. Once read them all in, your program should repeatedly prompt the user to enter in commands. Your program should support three main types of commands.

The user can enter a command of the form show me contact X. In this case, X is the full name of a person (meaning that, it can have spaces in it). If the command that a user types begins with show me contact, then you should check to see if the name X is in the contact list. If it is, you should report the contact info like so:

X's contact info: email: A phone: B 

However, you should replace X, A, and B with the actual name, email, and phone number. If the name does not exist, then you should print:

Not sure who that is. 

Either way, after processing the command, the program should prompt the user for the next command afterward.

When add contact is typed, the program will continue to prompt the user for three additional values: The name, email, and number of the contact. Once it prompts the user for these three things, the program will add this new contact to the list(s) of contact info that are stored in the program. Below is an example of what this should look like:

> add contact name: X email: Y phone: Z contact added! 

This is what it would look like, but the X, Y, and Z values will be custom values entered by the user. Each time an add contact command is processed, a new contact should be added to the list. You do not need to validate that X, Y, and Z are any particular type of input.

If the user types exit (all lower case) then the program should print an exit message and end. For example:

> exit Goodbye! 

When you exit the program, you should make sure to save the contents of the contact info lists back into the contacts.txt file. This is important so that your program will remember all of the newly-added contacts when it runs again in the future.

If contacts were added via the add contact command, these must be saved into the contacts.txt file, using the format described earlier.

If any other command is entered, your program should print Huh? and then prompt the user for another command.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!