diff --git a/Phonebook.py b/Phonebook.py new file mode 100644 index 0000000..eb89070 --- /dev/null +++ b/Phonebook.py @@ -0,0 +1,32 @@ +phonebook = {} # Empty dictinary to hold the details + +# +# Write your code in this area. +# + +if __name__=="__main__": + # Create some entries then show the phonebook + print("# Creating some entries...") + add_entry('A A','0123456789','abc@def.com','Coventry, CV3 3AB') + add_entry('A B','1234567890','xyz@abc.com') + add_entry('C C','2345678901') + add_entry('D D') + print("# Showing the phonebook") + show_phonebook() + # Test searching + print("# Testing searching") + show_entry('A A') + print("## Searching for 'A' yields:") + search('A') + # Check errors + print("# Checking error handling") + print("## Remove non-existing 'B B'") + try: + remove_entry('B B') + except Exception as e: + print("Error:", e.__class__.__name__, e) + print("## Showing non-existing 'B B'") + try: + show_entry('B B') + except Exception as e: + print("Error:", e.__class__.__name__, e)