Letter frequencies · 文字の頻度
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.
文字の出現頻度
ストリング内の各文字が何回出現しているかを示す辞書(ダイクショナリ)を返します。"aab" に対しては {"a": 2, "b": 1} です。
便利な手間は freq.get(ch, 0) です。ch の現在のカウントを読み出し、まだ見たことがない場合は 0 を返します。1 を加算して保存します。
Write char_frequency(s) that returns a dictionary mapping each character in s to the number of times it appears. · char_frequency(s) を書いて、s の各文字が何回出現するかをマッピングする辞書を返してください。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。