stuff
This commit is contained in:
@ -1,2 +1,15 @@
|
||||
def word_stats(filename, n):
|
||||
pass
|
||||
words = open(filename).read().replace('\n', '').lower().split()
|
||||
words = [''.join(e for e in w if e.isalpha()) for w in words]
|
||||
out = {}
|
||||
for word in words:
|
||||
if word in out.keys():
|
||||
out[word]['count'] += 1
|
||||
else:
|
||||
out[word] = {'count': 0, 'word': word}
|
||||
|
||||
out = sorted(out, key=lambda x:x[0])
|
||||
|
||||
return out
|
||||
|
||||
o = word_stats('article.txt', 5)
|
||||
|
Reference in New Issue
Block a user