13
13
import json
def load_contacts():
try:
return json.load(f)
except FileNotFoundError:
return []
def save_contacts(contacts):
json.dump(contacts, f, indent=4)
def add_contact(contacts):
print("Contact added.")
def view_contacts(contacts):
if not contacts:
return
if not results:
return
return
contacts.remove(contact)
print("Contact deleted.")
return
def main():
contacts = load_contacts()
while True:
print("\nContact Manager")
print("6. Exit")
if choice == "1":
add_contact(contacts)
view_contacts(contacts)
save_contacts(contacts)
break
else:
if __name__ == "__main__":
main()
Output:
Contact Manager
1. Add Contact
2. View Contacts
3. Search Contact
4. Update Contact
5. Delete Contact
6. Exit
Enter choice: 2
Name: Harsh, Phone: 1234567890, Email: [email protected], Address:123 Main St, sangamner
Name: Pranav, Phone: 9876543210, Email: [email protected], Address:456 Elm St, nashik
Contact Manager
1. Add Contact
2. View Contacts
3. Search Contact
4. Update Contact
5. Delete Contact
6. Exit
Enter choice: 1
Contact added.
Contact Manager
1. Add Contact
2. View Contacts
3. Search Contact
4. Update Contact
5. Delete Contact
6. Exit
Enter choice:6