0% found this document useful (0 votes)
5 views2 pages

Simple Python Contact Book Project

Uploaded by

srivishnubanda
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Simple Python Contact Book Project

Uploaded by

srivishnubanda
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assignment Format

Student Name Banda Srivishnu

Student Registration Number 252U1R6025 Class & Section:

Study Level : UG/PG UG Year & Term: I&I

Subject Name Problem Solving With Python

Name of the Project Simple Contact Book

Date of Submission 06-12-2025

Code:
contacts = {}

def add_contact():
name = input("Enter contact name: ").strip().title()
if name in contacts:
print(f"Contact '{name}' already exists.")
return

phone_number = input("Enter phone number: ").strip()


email = input("Enter email address (optional): ").strip()

contacts[name] = {
'phone': phone_number,
'email': email if email else 'N/A'
}
print(f"Contact '{name}' added successfully.")

def view_contacts():
if not contacts:
print("No contacts to display.")
return

print("\n--- Your Contacts ---")


for name, details in [Link]():
print(f" Name: {name}")
print(f" Phone: {details['phone']}")
print(f" Email: {details['email']}")
print("-" * 20)

def delete_contact():
name = input("Enter the name of the contact to delete: ").strip().title()
if name in contacts:
del contacts[name]
print(f"Contact '{name}' deleted successfully.")
else:
print(f"Contact '{name}' not found.")

def main_menu():
while True:
print("\n--- Contact Book Menu ---")
print("1. Add Contact")
print("2. View Contacts")
print("3. Delete Contact")
print("4. Exit")

choice = input("Enter your choice (1-4): ").strip()

if choice == '1':
add_contact()
elif choice == '2':
view_contacts()
elif choice == '3':
delete_contact()
elif choice == '4':
print("Exiting Contact Book. Goodbye!")
break
else:
print("Invalid choice. Please enter a number between 1 and 4.")

main_menu()

BY :

LG : 3

You might also like