Introduction
Create Address Book in Python
In today’s fast-paced world, staying connected with the people who matter most can be a challenge. Whether it’s family, friends, or colleagues, keeping their contact information organized and accessible is essential. That’s where an Address Book in Python comes in. This college project isn’t just about writing code—it’s about creating a personal, practical tool that brings order to the chaos of our busy lives. As you embark on this journey, you’re not just learning Python; you’re building a bridge to the people who enrich your world, one line of code at a time.
Table of Contents
Core Features
- Add New Contacts: Gather details like name, phone number, and email address.
- Update Existing Contacts: Modify information as needed.
- Delete Contacts: Remove entries that are no longer needed.
- Search for Contacts: Quickly find a contact by entering a name or other details.
- Display All Contacts: Show all stored contacts in a neat, organized format.
Step-by-Step Guide
1. Setting Up Your Python Environment
First, confirm that Python is set up on your computer. It is available for download on the official Python website. Choose an Integrated Development Environment (IDE) like PyCharm, VS Code, or even IDLE for writing your code.
2. Designing
We’ll use a list to store our contacts, where each contact is represented by a dictionary containing the name, phone number, and email. This simple structure is ideal for handling the necessary data efficiently.
contacts = []
3.Add New Contacts
The key feature of this Address Book is its ability to take input directly from the user. Let’s start by writing a function that allows the user to add a new contact.
Add a New Contact:
def add_contact():
name = input("Enter the contact's name: ")
phone = input("Enter the contact's phone number: ")
email = input("Enter the contact's email address: ")
contact = {
'name': name,
'phone': phone,
'email': email
}
contacts.append(contact)
print(f"Contact {name} added successfully!")
# Example usage
add_contact()
Here, the program prompts the user for the contact’s name, phone number, and email address, storing this information in a dictionary that is then added to the contacts list.
4. Searching
Search for a Contact:
def search_contact():
name = input("Enter the name of the contact to search for: ")
for contact in contacts:
if contact['name'].lower() == name.lower():
print(f"Name: {contact['name']}, Phone: {contact['phone']}, Email: {contact['email']}")
return
print("Contact not found.")
# Example usage
search_contact()
This function allows the user to input a name and then searches through the contacts list to find and display the corresponding details.
5. Updating and Deleting
You’ll need features to add and remove contacts from your Address Book in order to give it greater functionality.
Update a Contact:
def update_contact():
name = input("Enter the name of the contact to update: ")
for contact in contacts:
if contact['name'].lower() == name.lower():
new_phone = input("Enter the new phone number: ")
new_email = input("Enter the new email address: ")
contact['phone'] = new_phone
contact['email'] = new_email
print(f"Contact {name} updated successfully!")
return
print("Contact not found.")
# Example usage
update_contact()
Delete a Contact:
def delete_contact():
name = input("Enter the name of the contact to delete: ")
global contacts
contacts = [contact for contact in contacts if contact['name'].lower() != name.lower()]
print(f"Contact {name} deleted successfully!")
# Example usage
delete_contact()
6. Displaying All Contacts
Finally, create a function that displays all stored contacts in a user-friendly format.
Display All Contacts:
def display_contacts():
if not contacts:
print("No contacts available.")
else:
for contact in contacts:
print(f"Name: {contact['name']}, Phone: {contact['phone']}, Email: {contact['email']}")
# Example usage
display_contacts()
This function loops through the contacts list and prints out each contact’s details, ensuring that users can easily view all their contacts.
- New Project :-https://www.youtube.com/@Decodeit2
- PHP PROJECT:- CLICK HERE
- create address book in python
- connect with mysql and create address book in python
- create address book in word
- create address book in gmail
- address book in python
- address book project in python
- address book codehs
- Create Address Book in Python with Source Code