Nouvelle version du dimanche

This commit is contained in:
Alban
2026-03-08 13:25:06 +01:00
parent 582179ea9a
commit b71ae96310
5 changed files with 72 additions and 11 deletions

View File

@@ -5,10 +5,23 @@ _repertoire = {
"Bob": "0600000002"
}
def lecture():
with open('repertoire.txt','r') as f:
for ligne in f:
ligne = ligne.replace("\n","")
nom,numero=list(ligne.split(";;"))
_repertoire[nom]=numero
return _repertoire
def rechercher(nom: str) -> str:
"""Renvoie le numéro si le nom existe, sinon 'Inconnu'."""
return _repertoire.get(nom, "Inconnu")
def ajouter(nom: str, numero: str) -> None:
"""Ajoute ou remplace une entrée du répertoire."""
_repertoire[nom] = numero
with open('repertoire.txt','a') as f :
f.write(nom)
f.write(';;')
f.write(numero)
f.write("\n")