Skip to content
Open
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
15 changes: 15 additions & 0 deletions Most_occuring_word
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
fname = input('Enter file name: ')
fhand = open(fname)
counts = dict()
temp = list()
for line in fhand: #read each line
words = line.split() #list of words in line
for word in words:
counts[word] = counts.get(word,0) + 1
bigword = None
bigcount = 0
for k,v in counts.items():
if v > bigcount:
bigcount = v
bigword = k
print(bigword, bigcount)