Log In
NP Code Competition

Do I repeat myself?

Back to Problem Listing
Write a function called most_used that takes in a string. This string can be any arbitrary chunk of English text. Return a list of the 3 most common words that appear in the text in order of the most common first. (It doesn't matter how you handle ties, as the auto-grader sample text will not have any)

A word is any continuous set of characters comprised of the 26 letters of the alphabet or apostrophes. "CAT" is the same word as "cat" and "He'll" is NOT the same word as "hell".
Hyphenated words count as separate words.
You may assume there will be enough words in the text to have 5 most common words without ties.

Results must be returned as lowercase letters.

Sample

>>> most_used("d a b c a b c e a f a c d c b b e a b d a")
['a', 'b', 'c']
>>> most_used("Candy. meow! MEOW?!?! the-meow...the, (the) candy!!!! THE END")
['the', 'meow', 'candy']
This contest has ended. No more answers will be accepted.