Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions python/src/contacts.py

This file was deleted.

Empty file added python/src/contacts/__init__.py
Empty file.
22 changes: 22 additions & 0 deletions python/src/contacts/contacts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
def show_contacts(address_book):
print("\nContacts:\n")
for contact in address_book:
print(f"{contact['name']} {contact['email']} : {contact['phone']}")


def add_contact(address_book):
new_contact = {}
print("\nAdding a contact\n")
for s in ["name", "phone", "email"]:
new_contact[s] = input(f"Enter {s}: ")
address_book.append(new_contact)


def delete_contact(address_book):
print("\nDeleting one or more contacts\n")
partial = input("Enter a part of their name: ").lower()
print(f"Deleting contacts with name matching {partial}")
for ndx, contact in enumerate(address_book):
if partial in contact["name"].lower():
print(f"Deleting {contact['name']}")
address_book.pop(ndx)
41 changes: 34 additions & 7 deletions python/src/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
import contacts
import contacts.contacts

addressbook = []
address_book = [
{"name": "Bruce Wayne", "phone": "555-123-4567", "email": "bruce@wayne.com"},
{"name": "Clark Kent", "phone": "555-222-3333", "email": "clark@dailyplanet.com"},
{"name": "Diana Prince", "phone": "555-444-5555", "email": "diana@amazon.com"},
]
menus = [
"[1] Display all contacts",
"[2] Add a new contact",
"[3] Delete a contact",
"[4] Exit",
]

def menu():
pass

def main():
pass
def main(address_book):
selection = ""
while selection != "4":
for menu in menus:
print(menu)
selection = input("Enter a selection: ")
match selection:
case "1":
contacts.contacts.show_contacts(address_book)
case "2":
contacts.contacts.add_contact(address_book)
case "3":
contacts.contacts.delete_contact(address_book)
case "4":
print("Goodbye!")
case "5":
contacts.contacts.delete_proper(address_book)
case _:
print("That selection is not valid, please try again!")
print("")

main()

main(address_book)