Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
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)