Dear friends,
I am a new programmer and i have a task to make a phonebook with python. Please help me to finish my task.
The program should repeatedly ask the user for input. Each primary input is one of the words
“help”, “lookup”, “enter”, “remove”, and “quit”. If the user types in something else, the
program should show help. For some primary inputs, the program asks secondary input:
help: no secondary input; the program just prints information about available
commands and their inputs
lookup: secondary input is a name; the (final) program looks up the number for that name
(if any)
enter: secondary input consists of a name and a phone number; the (final) program
registers the number with the name
remove: secondary input is a name; the (final) program removes the name (if any) and
corresponding number
quit: no secondary input; the program ends
The actual functions of the final program will be filled in during the next block of
assignments. To prepare for the next version of the program, supply the secondary input to these functions now. Also, each function (except for help) will need a parameter for the phonebook, so supply it here already – for now, use a variable in the program that is
initialized to “{}” (a pair of curly braces, i.e. an empty dictionary).
Add persistence to the phonebook program by using module shelve. “Persistence” means that
data is retained also when the program stops executing.
Objects created by opening a “shelve” behave largely like dictionaries. So we may replace the dictionary by a “shelve”, and the functions that alter the phonebook should still work.
The only differences are in the main program. At the start of the program, open the “shelve” object – if no corresponding file is present, module shelve creates an empty “shelve”. At the end of the program, close the “shelve” object again.
Thank you for your attention. I am waiting for the reply as soon as possible. I stuck with this task.