Skip to content
Permalink
Browse files
Base code - to be extended by the students
  • Loading branch information
ab3735 committed Nov 16, 2018
1 parent a6b9d62 commit 4d7a9d779a89f52b4f2ebc3403771cbd12616c87
Showing 1 changed file with 32 additions and 0 deletions.
@@ -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)

0 comments on commit 4d7a9d7

Please sign in to comment.