Friday, November 28, 2014

Dr.Chuck S




name = raw_input('Enter file:')
handle = open(name, 'r')
text = handle.read()
words = text.split()
counts = dict()
for word in words:
counts[word] = counts.get(word,0) + 1
bigcount = None
bigword = None
for word,count in counts.items():
if bigcount is None or count > bigcount:
bigword = word
bigcount = count
print bigword, bigcount



This program opens a text file and then counts the words, it then prints the count.

This is a difficult program to understand if you do not know programming.

So in a  further post we'll break it down

No comments:

Post a Comment