# Définition d'une liste pour stocker les tâches taches = [] # Fonction pour ajouter une tâche à la liste def ajouter_tache(): tache = input("Entrez la tâche à ajouter : ") taches.append(tache) print("Tâche '{}' ajoutée avec succès.".format(tache)) # Fonction pour afficher la liste des tâches def afficher_taches(): if taches: print("Liste des tâches :") for i, tache in enumerate(taches, start=1): print("{}. {}".format(i, tache)) else: print("Aucune tâche enregistrée.") # Fonction pour supprimer une tâche de la liste def supprimer_tache(): afficher_taches() if taches: choix = int(input("Entrez le numéro de la tâche à supprimer : ")) if 1 <= choix <= len(taches): tache_supprimee = taches.pop(choix - 1) print("Tâche '{}' supprimée avec succès.".format(tache_supprimee)) else: print("Numéro de tâche invalide.") else: print("Aucune tâche à supprimer.") # Boucle principale while True: print("\nGestionnaire de tâches") print("1. Ajouter une tâche") print("2. Afficher les tâches") print("3. Supprimer une tâche") print("4. Quitter") choix = input("Entrez le numéro de l'opération souhaitée : ") if choix == "1": ajouter_tache() elif choix == "2": afficher_taches() elif choix == "3": supprimer_tache() elif choix == "4": print("Au revoir !") break else: print("Opération non valide. Veuillez choisir une option valide.")