================================================================================
  Question 5: Menu-Driven Phonebook Application (Dictionary CRUD)
================================================================================

FULL QUESTION:
Build a menu-driven application that uses the data structure dictionary to
create, update, search, and delete phonebook entries.

SHORT QUESTION:
Phonebook management system performing Create, Read, Update, and Delete (CRUD) operations on contacts using a dictionary.

================================================================================
README & SETUP INSTRUCTIONS:
================================================================================
# Question 5: Menu-Driven Phonebook Application (Dictionary CRUD)

- Prerequisites: Python 3.x (Standard library only).
- Setup: None.
- How to Run: python question_05.py
- Expected Behavior: Interactive menu to add contacts, search by name, update phone numbers, delete contacts, and display all entries.

================================================================================
SOURCE CODE FILES:
================================================================================

1. question_05.py
--------------------------------------------------------------------------------
phonebook = {'ashbi': '9656270150'}

menu = "\n 1. Create\n 2. Update\n 3. Search\n 4. Delete\n 0. Exit"

print(menu)
choice = int(input("Enter your choice: "))

while choice != 0:
    if choice == 1:
        name = input("Enter the name: ").strip()
        phone = input("Enter the phone number: ").strip()

        if name and phone:
            phonebook[name] = phone
            print("New contact created successfully.")
        else:
            print("Name and phone number cannot be empty.")

    elif choice == 2:
        search = input("Enter the name to be updated: ").strip()

        if search in phonebook:
            new_phone = input("Enter the new phone number: ").strip()
            if new_phone:
                phonebook[search] = new_phone
                print("Contact updated successfully.")
            else:
                print("Update failed: Phone number cannot be empty.")
        else:
            print(f"Error: {search} not found in the phonebook.")

    elif choice == 3:
        search = input("Enter the name to search: ").strip()
        if search in phonebook:
            print(f"Found -> {search}: {phonebook[search]}")
        else:
            print(f"Error: {search} not found in the phonebook.")

    elif choice == 4:
        name = input("Enter the name to delete: ").strip()
        if name in phonebook:
            del phonebook[name]
            print("Delete Successful.")
        else:
            print(f"Error: {name} not found in the phonebook.")

    elif choice == -1:
        print("Invalid input! Please enter numbers only (0-4).")
    else:
        print("Invalid choice! Please choose a number from 0 to 4.")

    print("\nCurrent Phonebook:", phonebook)
    print(menu)
    choice = int(input("Enter your choice: "))

print("Exiting..")
--------------------------------------------------------------------------------
