Top Words by Frequency

easy
Unit 1 · Strings I0/3 to milestone

Implement top_words(text, n) returning the n most common words as a list of (word, count) tuples.

  • Lowercase everything.
  • A word is a run of letters a-z or apostrophes (use a regex).
  • Sort by count descending, then alphabetically for ties.
#strings#collections2 visible + 0 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Top Words by Frequency · TechGradify