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의 각 문자가 나타나는 횟수를 매핑하는 사전(dictionary)을 반환하십시오.
Click Run to see the output here. · 출력을 보려면 '실행'을 클릭하세요.