Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Python-Home-Challenges/recurring word.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

where_file = input('Enter the file route: ')
with open(where_file,"r") as file:
my_file =file.readlines()
words_in_text = dict()
for line in my_file:
line = line.strip()
words = line.split(" ")
for word in words:
if word in words_in_text:
words_in_text[word] = words_in_text[word] + 1
else:
words_in_text[word] = 1
for key in list(words_in_text.keys()):
print(key, ":", words_in_text[key])
print("---------------")
max1=0
for highest in list(words_in_text.keys()):
if max1 < words_in_text[highest]:
max1 = words_in_text[highest]
key1 = highest
print (("The most recurring word is: {key12} with {max12} times").format(key12=key1,max12=max1))
3 changes: 3 additions & 0 deletions Python-Home-Challenges/saar.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
saar saar saar saar saar saar saar saar my bdd dss ass aa oeoeoe qwiwie xcld saar
saar lol sms iphone ani vao
haha jaja saar