ΕΛΥΣΑ ΤΟ ΠΡΟΓΡΑΜΜΑ ΤΟΥ CHATGPT !

preview_player
Показать описание
Σε αυτό το βίντεο επιτέλους έλυσα το πρόγραμμα που με έβαλε να κάνω το chatgpt !

Ακολούθησέ με:

#chatgpt #programming
Рекомендации по теме
Комментарии
Автор

list_of_contacts = []

def print_menu():

print("a. Add a new contact")
print("b. Search for a contact")
print("c. Display all contacts")
print("d. Delete a contact")
print("e. Exit the program")


def create_contact(name, phone, address):
contact={
"name":name,
"phone":phone,
"address":address
}


def search_contact(name):
found = False
print("__SEARCHING ALL CONTACTS__")

for contact in list_of_contacts:
if contact["name"] == name:
print("Name: ", contact["name"], "\nTel number: ", contact["phone"], "\nAddress:
found = True
break
if not found:
print("Sorry contact with name", name, "was not found")


def print_list():
print("__PRINTING ALL CONTACTS__")
for contact in list_of_contacts:
print("Name: ", contact["name"], "\nTel number: ", contact["phone"], "\nAddress:

def delete_contact(name):
print("__DELETING CONTACT__")
found = False

for contact in list_of_contacts:
if contact["name"] == name:

print("Contact with name:", name, "was deleted")
found = True
break
if not found:
print("Sorry contact with name", name, "was not found")



while(True):

print_menu()

option = input("Enter your option: ")

match option:
case "a":
name = input("Enter name : ")
phone = ""
while not phone.isdigit():
phone = input("Enter phone : ")
address = input("Enter address : ")
create_contact(name, phone, address)
case "b":
name = input("Enter name to search: ")
search_contact(name)
case "c":
print_list()
case "d":
name = input("Enter name to delete: ")
delete_contact(name)
case "e":
print("terminating program ...")
break
case _:
print("Unknown data")

CodeGRrow