forked from taylo403/121COM-Retake-Assignment
Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |