Guided pathThis is part of Understand Transformers & BERTBack to the path

Tally the words in a text

P42.from-paper-to-notebook.01 · Audience: guest, language-pro, it-ml · Prerequisites: Choosing with if

Real LLM grading for this pageLLM grading (this page):

Here is a task you have almost certainly done by hand: go through a text and count how often each word appears. On paper you add a gate mark under each word and count the marks at the end — slow, and one missed mark spoils the count. This is the capstone of the discipline: everything you have learned, turned on a real job. This first module does the word tally — a loop and a dictionary, working together.

Step 1 / 3The paper way, and why it is slow
ⓘ Concept: Counting by hand does not scale
To tally words on paper you keep a mark beside each word and add one every time it reappears, then total the marks. It works for a short note. For a transcript it is slow, and a single missed or double mark makes the final count wrong with no way to tell. The notebook does the same counting — but exactly, and instantly.

Why it matters — Seeing the manual task clearly is what makes the notebook version feel worth learning: you are automating something you already know how to do.

Ask the mentor about this module

Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.

Ctrl/Cmd + Enter to send

🎓 Practice ladder

1 graded rung · ~7 min

Your turn: fill in the loop so the dictionary tallies every word in the text. The frequency table is built for you. Press Run.

Explorer rung — tally the words

Loading exercise…