Skip to content · ⁨Passer au contenu⁩

Letter frequencies · ⁨Fréquences des lettres⁩

English

Letter frequencies

Return a dictionary that tells you how many times each character appears in a string. For "aab" that is {"a": 2, "b": 1}.

The handy move is freq.get(ch, 0) — it reads the current count for ch, or 0 if you haven't seen it yet. Add 1 and store it back.

Français

Fréquences de lettres

Retournez un dictionnaire indiquant combien de fois chaque caractère apparaît dans une chaîne. Pour "aab" c'est {"a": 2, "b": 1}.

Le coup de main est freq.get(ch, 0) — il lit le compte actuel pour ch, ou 0 si vous ne l'avez jamais vu. Ajoutez 1 et stockez-le en retour.

Log in or create account · ⁨Se connecter ou créer un compte⁩

IGCSE, A-Level & AP