Python program to find the first repeated word in a string

Spread the love

In this tutorial, you will learn how to write a python program to find the first repeated word in a string

from collections import Counter

text = "python is the best best programming language"

split = text.split(' ')

print(split)
data = Counter(split)
for key in data:
if dict[key]>1:
print (key)

Output:

best

admin

admin

Leave a Reply

Your email address will not be published. Required fields are marked *