CoddyRun
Fonction Utilitaires

pluriel(nb, mot)

Écrit un nombre suivi du mot au singulier ou au pluriel : "1 pomme", "3 pommes".

Partagée par CoddyRun · CoddyRun 7 novembre 2026

Explication

En français, 0 et 1 restent au singulier ; à partir de 2, on ajoute un « s ».

Pour un pluriel irrégulier (cheval → chevaux), écrivez plutôt sialors(nb >= 2, "chevaux", "cheval").

Code

fonction pluriel(nb, mot)
    si absolue(nb) >= 2 alors
        retourne convertir_texte(nb) + " " + mot + "s"
    fin si
    retourne convertir_texte(nb) + " " + mot
fin fonction

Exemple d'utilisation

affiche "Il te reste " + pluriel(1, "vie")
affiche "Tu as ramassé " + pluriel(3, "pièce")
affiche pluriel(0, "point")

Commentaires (0)

Pas encore de commentaire. Une question, une amélioration, un merci ? Lancez-vous.

Connectez-vous ou créez un compte pour commenter.

Du même auteur