Exemplo n.º 1
0
print(f"Phone Agenda CLI".center(50, "-"))

while True:
    try:
        print(f"Available options:".center(50, "="))
        print(
            "(a) To add contacts.\n(d) To delete contacts.\n(s) To save contacts into Excel file."
        )
        user_choice = input("\nWhat do you want to do?: ")
        if user_choice == "a":
            contact_name = input("Enter contact name: ")
            if len(contact_name.strip(" ")) == 0:
                print("Names cannot be empty.")
                continue
            elif contacts.contact_exists(contact_name):
                print("Contact already exists.")
                continue
            else:
                contact_phone = input("Enter contact phone: ")
                if len(contact_phone.strip(" ")) == 0:
                    print("Numbers cannot be empty.")
                    continue
                else:
                    contact = {"name": contact_name, "phone": contact_phone}
                    contacts.add_contacts(contact)
                    print("Contact added.\n")
                    continue
        elif user_choice == "d":
            contacts.delete_contact()
            continue