3 ms·
Here's mine for what it's worth, since this is one of the Google python assignments. Admittedly, i'm not very proficient at all. def get_file_words(filename
by krapp 13y ago
Here's mine for what it's worth, since this is one of the Google python assignments. Admittedly, i'm not very proficient at all.
def get_file_words(filename):
file = open(filename, 'rU')
words = {}
for line in file:
for word in [word.lower() for word in line.split()]:
if not word in words.keys():
words[word] = 1
else: words[word]+=1
return words
def print_words(filename):
wordcount = get_file_words(filename)
for word in wordcount:
print word, wordcount[word]