Permalink
Cannot retrieve contributors at this time
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?
121COM-Retake-Assignment/phonebook code
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
29 lines (21 sloc)
799 Bytes
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
phonebook = {} # Empty dictinary to hold the details | |
#adding the information in the add entry function | |
def add_entry(index, phonenumber = None, email = None,address = None): | |
phonedetails = {"Tel": phonenumber, | |
"email": email, | |
"Address": address | |
} | |
global phonebook | |
phonebook.update({index : phonedetails}) | |
#Function to show the phonebook | |
def show_phonebook(search): | |
print("# Showing the phonebook") | |
global phonebook | |
print(phonebook[search]) | |
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','0123456333','abc@lll.com') | |
show_phonebook('A B') | |
print("# Showing the phonebook") | |