-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprojet_guide.py
More file actions
41 lines (33 loc) · 1.17 KB
/
projet_guide.py
File metadata and controls
41 lines (33 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#1
contacts = []
#Ajouter
def ajouter_contact(contacts, nom, telephone, email):
contact = {"nom": nom, "telephone": telephone, "email": email}
contacts.append(contact)
#Supprimer
def supprimer_contact(contacts, nom):
for contact in contacts:
if contact["nom"] == nom:
contacts.remove(contact)
break
#Afficher
def afficher_contacts(contacts):
for contact in contacts:
print(f"Nom: {contact['nom']}, Téléphone: {contact['telephone']}, Email: {contact['email']}")
#Action
while True:
action = input("Que voulez-vous faire ? (ajouter/supprimer/afficher/quitter) : ")
if action == "ajouter":
nom = input("Entrez le nom : ")
telephone = input("Entrez le numéro de téléphone : ")
email = input("Entrez l'adresse e-mail : ")
ajouter_contact(contacts, nom, telephone, email)
elif action == "supprimer":
nom = input("Entrez le nom du contact à supprimer : ")
supprimer_contact(contacts, nom)
elif action == "afficher":
afficher_contacts(contacts)
elif action == "quitter":
break
else:
print("Action non reconnue. Veuillez réessayer.")