incroyable.py

Created by alban-scientifique

Created on November 07, 2023

1.57 KB


# 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.")

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.