📊
Word frequency
Count how often each word shows up in a chunk of text.
Maker· ages 12–1425 mindictssortedlambdastring methods
wordfreq.py
…First load pulls ~10 MB of Python. Only happens once — the browser caches it after.
What should the output look like?
You should see a ranked list of the most-common words with a bar and count for each.
📖
How this works
Counts how often each word appears in a chunk of text. Uses a dict to store counts, sorted() to rank, and slicing ([:10]) to pick the top 10.
Your turn — try these
- 1Filter out short words (< 3 letters) before counting.
- 2Add punctuation stripping for `?`, `!`, `;`, `:`, and quotes.
- 3Compare two texts side-by-side — which words appear in one but not the other?