Skip to content
  • SiteMap
  • Our Services
  • Frequently Asked Questions (FAQ)
  • Support
  • About Us

UpdateGadh

Update Your Skills.

  • Home
  • Projects
    •  Blockchain projects
    • Python Project
    • Data Science
    •  Ai projects
    • Machine Learning
    • PHP Project
    • React Projects
    • Java Project
    • SpringBoot
    • JSP Projects
    • Java Script Projects
    • Code Snippet
    • Free Projects
  • Tutorials
    • Ai
    • Machine Learning
    • Advance Python
    • Advance SQL
    • DBMS Tutorial
    • Data Analyst
    • Deep Learning Tutorial
    • Data Science
    • Nodejs Tutorial
  • Blog
  • Contact us
  • Toggle search form
Contact Management in Python with Source Code - Contact Management in Python with Source Code

Contact Management in Python with Source Code

Posted on October 13, 2024October 13, 2024 By Rishabh saini No Comments on Contact Management in Python with Source Code

Contact Management in Python

Managing contacts efficiently is essential for both personal and professional purposes. Whether you’re handling a small list of friends or a large database of business clients, an organized system is key to keeping everything in check. While there are plenty of contact management software options available, building your own contact management system in Python can be an excellent learning experience. Not only will it sharpen your Python skills, but it can also be customized to fit your specific needs.

Table of Contents

  • Contact Management in Python
  • Features
  • Setting Up
    • 1. Defining the Contact Data Structure
    • 2. Creating Functions for Each Feature
      • Adding a New Contact
      • Viewing All Contacts
      • Searching for a Contact
      • Updating a Contact
      • Deleting a Contact
    • 3. Building the Main Menu
    • 4. Complete Source Code

Features

Our contact management system will provide the following functionalities:

  1. Add new contacts: Users can add a contact’s name, phone number, and email.
  2. View all contacts: Display all saved contacts in a readable format.
  3. Search for a contact: Users can search for a specific contact by name.
  4. Update contact information: Modify the details of an existing contact.
  5. Delete contacts: Remove contacts from the system.
  6. Exit the program: Exit the contact management system when done.

https://updategadh.com/category/php-project

Setting Up

1. Defining the Contact Data Structure

For simplicity, we will store contacts in a list of dictionaries, where each dictionary represents a contact. Each contact will have three key pieces of information: name, phone number, and email address.

contacts = []

2. Creating Functions for Each Feature

We’ll create individual functions to handle adding, viewing, searching, updating, and deleting contacts.

Download New Real Time Projects :-Click here

Adding a New Contact

The add_contact function will prompt the user to input the contact’s details and store them in the contacts list.

def add_contact():
    name = input("Enter contact name: ")
    phone = input("Enter contact phone number: ")
    email = input("Enter contact email: ")

    contact = {"name": name, "phone": phone, "email": email}
    contacts.append(contact)
    print(f"Contact {name} added successfully!")
https://updategadh.com/php-project/laundry-management-system-in-php/

Viewing All Contacts

The view_contacts function will loop through the contacts list and display all stored contacts.

def view_contacts():
    if contacts:
        print("\nContact List:")
        for idx, contact in enumerate(contacts, 1):
            print(f"{idx}. Name: {contact['name']}, Phone: {contact['phone']}, Email: {contact['email']}")
    else:
        print("No contacts found.")

Searching for a Contact

This function will allow users to search for a contact by name. It will look through the list and show the contact that matches.

def search_contact():
    search_name = input("Enter the name of the contact you're searching for: ")
    found = False
    for contact in contacts:
        if contact['name'].lower() == search_name.lower():
            print(f"Contact found: Name: {contact['name']}, Phone: {contact['phone']}, Email: {contact['email']}")
            found = True
            break
    if not found:
        print("Contact not found.")

Updating a Contact

In this function, the user can search for a contact by name and update their phone number or email.

def update_contact():
    search_name = input("Enter the name of the contact to update: ")
    for contact in contacts:
        if contact['name'].lower() == search_name.lower():
            print(f"Updating contact: {contact['name']}")
            contact['phone'] = input("Enter new phone number: ")
            contact['email'] = input("Enter new email: ")
            print(f"Contact {contact['name']} updated successfully!")
            return
    print("Contact not found.")

Deleting a Contact

The delete_contact function will search for a contact by name and remove it from the list.

def delete_contact():
    search_name = input("Enter the name of the contact to delete: ")
    for contact in contacts:
        if contact['name'].lower() == search_name.lower():
            contacts.remove(contact)
            print(f"Contact {contact['name']} deleted successfully!")
            return
    print("Contact not found.")

3. Building the Main Menu

We’ll create a simple menu-driven interface that loops and allows the user to choose which action they want to perform. The program will continue to run until the user chooses to exit.

def menu():
    while True:
        print("\nContact Management System")
        print("1. Add a new contact")
        print("2. View all contacts")
        print("3. Search for a contact")
        print("4. Update a contact")
        print("5. Delete a contact")
        print("6. Exit")

        choice = input("Enter your choice (1-6): ")

        if choice == '1':
            add_contact()
        elif choice == '2':
            view_contacts()
        elif choice == '3':
            search_contact()
        elif choice == '4':
            update_contact()
        elif choice == '5':
            delete_contact()
        elif choice == '6':
            print("Exiting program. Goodbye!")
            break
        else:
            print("Invalid choice. Please try again.")
Contact Management in Python
Contact Management in Python
Contact Management in Python
Contact Management in Python
Contact Management in Python
Contact Management in Python

4. Complete Source Code

Here’s the complete code for the contact management system:

contacts = []

def add_contact():
    name = input("Enter contact name: ")
    phone = input("Enter contact phone number: ")
    email = input("Enter contact email: ")

    contact = {"name": name, "phone": phone, "email": email}
    contacts.append(contact)
    print(f"Contact {name} added successfully!")

def view_contacts():
    if contacts:
        print("\nContact List:")
        for idx, contact in enumerate(contacts, 1):
            print(f"{idx}. Name: {contact['name']}, Phone: {contact['phone']}, Email: {contact['email']}")
    else:
        print("No contacts found.")

def search_contact():
    search_name = input("Enter the name of the contact you're searching for: ")
    found = False
    for contact in contacts:
        if contact['name'].lower() == search_name.lower():
            print(f"Contact found: Name: {contact['name']}, Phone: {contact['phone']}, Email: {contact['email']}")
            found = True
            break
    if not found:
        print("Contact not found.")

def update_contact():
    search_name = input("Enter the name of the contact to update: ")
    for contact in contacts:
        if contact['name'].lower() == search_name.lower():
            print(f"Updating contact: {contact['name']}")
            contact['phone'] = input("Enter new phone number: ")
            contact['email'] = input("Enter new email: ")
            print(f"Contact {contact['name']} updated successfully!")
            return
    print("Contact not found.")

def delete_contact():
    search_name = input("Enter the name of the contact to delete: ")
    for contact in contacts:
        if contact['name'].lower() == search_name.lower():
            contacts.remove(contact)
            print(f"Contact {contact['name']} deleted successfully!")
            return
    print("Contact not found.")

def menu():
    while True:
        print("\nContact Management System")
        print("1. Add a new contact")
        print("2. View all contacts")
        print("3. Search for a contact")
        print("4. Update a contact")
        print("5. Delete a contact")
        print("6. Exit")

        choice = input("Enter your choice (1-6): ")

        if choice == '1':
            add_contact()
        elif choice == '2':
            view_contacts()
        elif choice == '3':
            search_contact()
        elif choice == '4':
            update_contact()
        elif choice == '5':
            delete_contact()
        elif choice == '6':
            print("Exiting program. Goodbye!")
            break
        else:
            print("Invalid choice. Please try again.")

# Start the program
menu()
  • Contact Management in Python with Source Code
  • Contact Management in Python
  • Contact Management in Python with Source Code
Post Views: 874
code Snippets Tags:contact book project in python for beginners, contact book python, contact book using dictionary in python, contact management system, contact management system in python, contact management system project in python, contact management system project in python with source code, create a student management system in python in hindi, employee management system in python, student database managment system in python, student management system in python

Post navigation

Previous Post: Laundry Management System in PHP and MySQL
Next Post: Best Project Ideas for Beginner Students

More Related Articles

Blockchain Security - What is Blockchain Security code Snippets
Simple Library Menu in Java with Source Code - Simple Library Menu in Java Simple Library Menu in Java with Source Code code Snippets
Rental Management System in Java with Source Code - Rental Management System in Java with Source Code Rental Management System in Java with Source Code code Snippets

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may also like

  1. Supply Chain Management PHP and CSS
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. F1 Race Road Game in Python Free Source Code
  4. Supplier Management System in Java with Free Code
  5. Create Address Book in Python with Source Code
  6. Movie Management System in Python with Source Code

Most Viewed Posts

  1. Top Large Language Models in 2025
  2. Online Shopping System using PHP, MySQL with Free Source Code
  3. login form in php and mysql , Step-by-Step with Free Source Code
  4. Flipkart Clone using PHP And MYSQL Free Source Code
  5. News Portal Project in PHP and MySql Free Source Code
  6. User Login & Registration System Using PHP and MySQL Free Code
  7. Top 10 Final Year Project Ideas in Python
  8. Online Bike Rental Management System Using PHP and MySQL
  9. E learning Website in php with Free source code
  10. E-Commerce Website Project in Java Servlets (JSP)
  • AI
  • ASP.NET
  • Blockchain
  • ChatCPT
  • code Snippets
  • Collage Projects
  • Data Science Project
  • Data Science Tutorial
  • DBMS Tutorial
  • Deep Learning Tutorial
  • Final Year Projects
  • Free Projects
  • How to
  • html
  • Interview Question
  • Java Notes
  • Java Project
  • Java Script Notes
  • JAVASCRIPT
  • Javascript Project
  • JSP JAVA(J2EE)
  • Machine Learning Project
  • Machine Learning Tutorial
  • MySQL Tutorial
  • Node.js Tutorial
  • PHP Project
  • Portfolio
  • Python
  • Python Interview Question
  • Python Projects
  • PythonFreeProject
  • React Free Project
  • React Projects
  • Spring boot
  • SQL Tutorial
  • TOP 10
  • Uncategorized
  • Online Examination System in PHP with Source Code
  • AI Chatbot for College and Hospital
  • Job Portal Web Application in PHP MySQL
  • Online Tutorial Portal Site in PHP MySQL — Full Project with Source Code
  • Online Job Portal System in JSP Servlet MySQL

Most Viewed Posts

  • Top Large Language Models in 2025 (8,614)
  • Online Shopping System using PHP, MySQL with Free Source Code (5,215)
  • login form in php and mysql , Step-by-Step with Free Source Code (4,867)

Copyright © 2026 UpdateGadh.

Powered by PressBook Green WordPress theme