Exercise 1: Count Letters Per Word in a Paragraph — Possible Solution ==================================================================== text = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.""" # Quick sanity check against the tricky example first test_word = "h3ll!" count = 0 for ch in test_word: if ch.isalpha(): count += 1 print(f"{test_word}: {count}") words = text.split() for word in words: letter_count = 0 for ch in word: if ch.isalpha(): letter_count += 1 print(f"{word}: {letter_count}") Output (first few lines): h3ll!: 3 Lorem: 5 ipsum: 5 dolor: 5 sit: 3 amet,: 4 consectetur: 11 adipiscing: 10 elit.: 4 Sed: 3 ... laborum.: 7 WHY THIS WORKS AS AN ANSWER ------------------------------ text.split() breaks the paragraph into a list of words on whitespace alone, so punctuation stays glued to whichever word it's attached to ("amet," and "elit." keep their comma and period). That's exactly why the inner loop can't just use len(word) — it has to walk each character individually and only count the ones where ch.isalpha() is True, the same way the sanity-check line filters "h3ll!" down to just h, l, and l. Numbers and punctuation are silently skipped by the if check, never subtracted afterward — there's no separate "count everything, then subtract the junk" step needed.