-
-
Save beltiras/82d2c81c0a335b72cdd1931ccb218dd3 to your computer and use it in GitHub Desktop.
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
def menu_selection(): | |
try: | |
print("Menu:") | |
choice = str(input("add(a), remove(r), find(f):" )).lower | |
except ValueError: | |
print("please follow the directions above") | |
return choice | |
def execute_selection(choice, a_dict): | |
if choice == "a": | |
add_to_dict(a_dict) | |
return a_dict | |
elif choice == "r": | |
remove_from_dict(a_dict) | |
return a_dict | |
elif choice == "f": | |
find_key(a_dict) | |
return a_dict | |
def add_to_dict(a_dict): | |
add_key = input("Key:" ) | |
add_value = input("Value:" ) | |
a_dict[add_key] = add_value | |
return a_dict | |
#def remove_from_dict(a_dict): | |
#remove_key = input("Key to remove:" ) | |
def find_key(a_dict): | |
find = input("Key to locate" ) | |
if find in a_dict: | |
print(find, value ) | |
else: | |
print("Not found") | |
return a_dict | |
# Do not change this main function | |
def main(): | |
more = True | |
a_dict = {} | |
while more: | |
choice = menu_selection() | |
execute_selection(choice, a_dict) | |
again = input("More (y/n)? ") | |
more = again.lower() == 'y' | |
dictlist = dict_to_tuples(a_dict) | |
print(sorted(dictlist)) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment