Lab 1.2 Phone book application
You cannot submit for this problem because the homework's deadline is due.
Description
Use python3 to write a simple phone book application, where you can add, remove, and edit entries.
For add
, you can simply add or update people-phone number pair to the phonebook.
For edit
, if the name exists in the phonebook, it will be updated. Otherwise, nothing should happen.
For remove
, if the name exists in the phonebook, it will be removed. Otherwise, nothing should happen.
Moreover, a single line of quit
will end the program (see sample IO for details).
Submission Format
Submit a tar or zip file including a script named phonebook.py
.
IO
Input
Lines of operations.
Output
The current phonebook after each operation.
Sample IO
Input
add Jaxon 10089588646
add Theo 17857132412
edit Theo 17857795300
add Reggie 17525212962
remove Jaxon
edit Isaac 16806768266
remove Lucas
quit
Output
{'Jaxon': 10089588646}
{'Jaxon': 10089588646, 'Theo': 17857132412}
{'Jaxon': 10089588646, 'Theo': 17857795300}
{'Jaxon': 10089588646, 'Theo': 17857795300, 'Reggie': 17525212962}
{'Theo': 17857795300, 'Reggie': 17525212962}
{'Theo': 17857795300, 'Reggie': 17525212962}
{'Theo': 17857795300, 'Reggie': 17525212962}
Hint
- To separate the operation, name, phone number. Try to use
split()
. - Convert the phone number from string to int.
- Directly print the dict.