2nd most frequent word in a string | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

2nd most frequent word in a string

Can anyone make a program which prints 2nd most frequent word used in a string in python language

31st May 2019, 2:13 PM
Divyansh Kumar Mahavar
Divyansh Kumar Mahavar - avatar
1 Answer
+ 7
Python has a module for that, collections.Counter. Used on a string, Counter() will count the frequency of each letter. Used on a list with the single words of the string, it will count the words.
31st May 2019, 2:20 PM
Anna
Anna - avatar