Skip to content

kobbieessel/Phonebook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

PhoneBook — Terminal-based Contact Manager

Simple terminal-based phonebook application implemented in Python. It provides basic CRUD operations (Create, Read, Update, Delete) and stores contacts in a JSON file (phonebook.json) in the project directory.

Features

  • Add a contact (name, phone, email)
  • View all contacts with index numbers
  • Update a contact by name
  • Delete a contact by name
  • Stores contacts in phonebook.json using a list of objects

Requirements

  • Python 3.7+ (only standard library is required: os, json)

Quick start (Windows PowerShell)

  1. Open a PowerShell prompt in the project folder (where phonebook.py is located).
  2. Run the program:
python .\phonebook.py

Notes: If your system uses python3 for the Python 3 interpreter, use python3 .\phonebook.py instead.

How it works / Usage

When you run phonebook.py it will display a simple menu:

  • 0 — View contacts: prints all saved contacts from phonebook.json.
  • 1 — Add contact: prompts for Name, Phone, Email and saves the contact.
  • 2 — Update contact: prompts for the contact Name to find, then asks for new Name/Phone/Email.
  • 3 — Delete contact: prompts for the contact Name to delete.
  • 4 — Quit: exit the menu loop.

After each action you'll be asked whether to continue (y/n).

Validation: phone numbers are validated to contain only digits. If the phone is invalid when saving/updating, you'll be prompted to edit it; otherwise the contact will not be saved.

Data format

Contacts are stored in the file phonebook.json as a JSON array. Each contact is an object with the keys:

[
  {
    "name": "Alice",
    "phone": "1234567890",
    "email": "alice@example.com"
  }
]

If phonebook.json doesn't exist yet it will be created automatically when you add the first contact.

Examples

  • Add a contact: choose 1, then enter Kwabena, 0541234567, kwabena@example.com.
  • View contacts: choose 0.
  • Update: choose 2, enter the name of the contact to update, then provide new fields.
  • Delete: choose 3, enter the name of the contact to remove.

Known issues & notes

  • Searching for a contact to update/delete uses a simple membership check (it looks for the entered string among the contact object's values). This may match partial values or multiple contacts with the same name.
  • There is no advanced duplicate-detection or sophisticated search; consider adding exact-match or ID-based operations for larger datasets.

Development & contribution

To modify the program, edit phonebook.py. The project is a single-file, small learning project using OOP for the PhoneBook class.

Suggested improvements you can implement:

  • Add unit tests and a small CLI argument parser to support non-interactive operations.
  • Use a unique ID for contacts to avoid ambiguous updates/deletes.
  • Improve validation for emails and phone numbers (international formats).
  • Pretty-printing and sorting of the contact list.

Author

Kwabena Amoako Embedded Systems | Hardware & Firmware | Robotics

Social: LinkedIn

About

Phonebook Terminal Based App

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages