← Back to Gists

Count character frequency

📝 Python
tmedina
tmedina · Level 5 ·

Counts how often each character appears in a string and returns a dictionary of frequencies.

Python
def countcharfrequency(s): freq = {} for char in s: freq[char] = freq.get(char, 0) + 1 return freq

Comments

No comments yet. Start the discussion.