Skip to content

Commit

Permalink
Merge pull request #6601 from MazeJack/Adding/Python_contact_manageme…
Browse files Browse the repository at this point in the history
…nt_application

Adding/python contact management application
  • Loading branch information
ossamamehmood authored Oct 31, 2023
2 parents 5782939 + 4474de7 commit adfe113
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Add Code Here/Contact_management-application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
contacts = []

def add_contact():
name = input("Enter the contact's name: ")
number = input("Enter the contact's phone number: ")
contact = (name, number)
contacts.append(contact)
print("Contact added successfully.")

def list_contacts():
if not contacts:
print("No contacts found.")
else:
print("Your contacts:")
for i, (name, number) in enumerate(contacts, start=1):
print(f"{i}. {name}: {number}")

while True:
print("\nOptions:")
print("1. Add a contact")
print("2. List contacts")
print("3. Quit")

choice = input("Enter your choice: ")

if choice == "1":
add_contact()
elif choice == "2":
list_contacts()
elif choice == "3":
print("Exiting the Contact Management App.")
break
else:
print("Invalid choice. Please try again.")
34 changes: 34 additions & 0 deletions Add Code Here/PYTHON/Python_contact_management_application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
contacts = []

def add_contact():
name = input("Enter the contact's name: ")
number = input("Enter the contact's phone number: ")
contact = (name, number)
contacts.append(contact)
print("Contact added successfully.")

def list_contacts():
if not contacts:
print("No contacts found.")
else:
print("Your contacts:")
for i, (name, number) in enumerate(contacts, start=1):
print(f"{i}. {name}: {number}")

while True:
print("\nOptions:")
print("1. Add a contact")
print("2. List contacts")
print("3. Quit")

choice = input("Enter your choice: ")

if choice == "1":
add_contact()
elif choice == "2":
list_contacts()
elif choice == "3":
print("Exiting the Contact Management App.")
break
else:
print("Invalid choice. Please try again.")

0 comments on commit adfe113

Please sign in to comment.