def add_info():
    print()
    name = input("name: ")
    tag = input("tag: ") # email, cell, website, etc.
    info = input("info: ")
    entry = name + ";" + tag + ";" + info + "\n"
    file = open("/home/instructor/Desktop/addr.txt","a")
    file.write(entry)
    print("Wrote",entry)
    file.close()

def show_everything():
    print()
    file = open("/home/instructor/Desktop/addr.txt","r")
    for line in file:
        print(line.strip())
    file.close()
    print()

def lookup():
    print()
    found_something = False
    name = input("Type a name to look up: ")
    file = open("/home/instructor/Desktop/addr.txt","r")
    for line in file:
        if line.startswith(name):
            print(line.strip())
            found_something = True
    file.close()
    if found_something==False:
        print("I didn't find anything for", name)
    print()

def run_app():
    app_is_running = True
    while app_is_running:
        print("What would you like to do?")
        print("(a) Add information to the address book.")
        print("(l) Look up information.")
        print("(s) Show everything.")
        print("(q) Quit.")
        choice = input(">> ")
        if choice=="q":
            print("Bye!")
            app_is_running = False
        elif choice=="a":
            add_info()
        elif choice=="s":
            show_everything()
        elif choice=="l":
            lookup()
        else:
            print("I didn't understand your choice.")

run_app()


