Objective
Create a Python program that shows the three words that are repeated the most in a text using Counter.
Instructions
- Import
Counterfrom thecollectionsmodule. - Read a line of text with words separated by spaces, without punctuation marks, and convert it to lower case.
- Count the words with
Counterand get the three most common ones withmost_common(3). - Show one line per word with the format
word: times, from most to least frequent. If there is a tie, the one that appeared first in the text goes first. - If there are fewer than three distinct words, show only the ones there are.
el sol y el mar y el cielo
el: 3
y: 2
sol: 1
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise