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.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
53 lines (44 sloc)
1.32 KB
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 ={} | |
def print_menu(): | |
print('1. Phone Numbers') | |
print('2. Add Phone Number') | |
print('3. Wipe Phone Number') | |
print('4. Find Phone Number') | |
print('5. Exit') | |
print() | |
def show_phonebook(search): | |
global phonebook | |
print(phonebook[search]) | |
show_phonebook() | |
'''show_phonebook()''' | |
print("# Showing the phonebook") | |
if __name__== "__main__": | |
# Create some entries then show the phonebook | |
print("# Creating some entries...") | |
add_entry('myles123456789','myles@outlook.com','Coventry, CV1 4VB') | |
numbers ={} | |
menu_choice = 0 | |
print_menu() | |
while menu_choice != 5: | |
menu_choice = int(input("Type in a number (1-5): ")) | |
if menu_choice == 1: | |
print("Phone Numbers:") | |
elif menu_choice == 2: | |
print("Add Name and Number") | |
name = input("Name: ") | |
phone = input("Number: ") | |
print("Wipe Phone Number") | |
name = input("Name: ") | |
if name in numbers: | |
del numbers[name] | |
else: | |
print(name, "was not found") | |
elif menu_choice == 4: | |
print("Find Phone Number") | |
name = input("Name: ") | |
if name in numbers: | |
print("The number is", numbers[name]) | |
else: | |
print(name, "not found") | |
elif menu_choice != 5: | |
print_menu() |