Repeating & Choosing

A track of P41 · Functions & Reuse.

A loop does something to every item; if chooses which items — together they are the heart of automation.

Picture the column of words you would work through by hand — capitalise each one, or note how long each is. A loop is that patience, mechanised: it visits every item in a list and does the same thing to each, never skipping one and never getting tired at item forty. The first module lets you watch it walk, item by item, so the repetition stops being mysterious and starts being yours to command.

Make it concrete. Yesterday's transcript gave you three hundred words, and the style guide wants every one of them capitalised for the term index. By hand that is an afternoon of retyping, a sore wrist, and — somewhere around word two hundred — a lowercase entry you will not catch until the client does. The loop version is three short lines, runs in under a second, and treats word three hundred with exactly the care it gave word one. Now raise the stakes: you do not want all three hundred — only the long ones, say longer than eight letters, because those are the specialist terms that probably need a gloss. How many extra lines does the choosing cost? Fewer than you think, and that is the itch the second module exists to scratch.

The choosing has a name: if. Real work always has a glance-and-decide in the middle — keep this, skip that; flag the term, leave the common word — and if is that glance written down: a small question asked of each item as the loop passes, sorting it into do or don't. You already perform this exact judgement dozens of times a day with a pen in your hand; the module only teaches you to dictate the rule once instead of applying it three hundred times.

Put together — loop outside, if inside — the pair is the single pattern behind nearly every automation in the capstone ahead: the word tally, the vocabulary table, the find-and-replace across a whole document. That is why this track takes it slowly and lets you watch each pass happen. Master these two modules and you are no longer learning ingredients; the very next track is the meal.

A listyour column of wordsLoop visits eachone item at a timeif decideskeep it or skip itResults collectthe items you wanted
Loop plus if: repetition with a decision inside.