how to find most repeated word in a string in python

Solutions on MaxInterview for how to find most repeated word in a string in python by the best coders in the world

showing results for - "how to find most repeated word in a string in python"
Leni
28 Mar 2018
1from collections import Counter
2
3# Example phrase 
4phrase = "John is the son of John second. Second son of John second is William second."
5split_phrase = phrase.split()
6
7# create counter object
8Counter = Counter(split_phrase)
9
10most_occured_words = Counter.most_common(4)
11  
12print(most_occured_words)