How to find the 10 most commonly repeated words in a text using Python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to find the 10 most commonly repeated words in a text using Python?

28th Apr 2019, 10:36 PM
Ядрото
Ядрото - avatar
3 Answers
+ 13
What have you got so far? Post a link to your code and we can make suggestions. I'm thinking you might use: input().split() to convert text into a list of words, splitting on spaces (you will probably want to remove capitals, commas and periods, etc.) set() to remove multiples count() to count occurrences of each word of the set in the list sorted() to put the words in order of frequency slicing to list the top ten
28th Apr 2019, 10:51 PM
David Ashton
David Ashton - avatar
+ 7
Here are a few lines of code to demonstrate some of the principles https://code.sololearn.com/cbjn7Fjf3W85/?ref=app
30th Apr 2019, 7:31 AM
David Ashton
David Ashton - avatar
0
David's answer probably explained all the step required to make it work .He indirectly answered your question, all you need to do is research all the stuff that you don't understand such as set() or split().
29th Apr 2019, 3:01 AM
Leon lit
Leon lit - avatar