![filename=one.txt 1 s = open(filename). read(). split() 7 for word in s if word in f: f[word] +=1 else: 10 f[word] = 1 12 13](http://img.homeworklib.com/questions/15cc4ca0-b78e-11eb-8a95-830c0c54b17c.png?x-oss-process=image/resize,w_560)
filename = "one.txt"
s = open(filename).read().split()
f = {}
for word in s:
if word in f:
f[word] +=1
else:
f[word] = 1
s = [(one, f[one]) for one in sorted(f, key = f.get, reverse = True)]
for i in range(10):
print(s[i][0],":", s[i][1])
''' OUTPUT
King : 3
Once : 1
there : 1
lived : 1
a : 1
went : 1
for : 1
fishing : 1
and : 1
has : 1
'''
use python 019/Lab3.pdf python Exercise 2 Find out most common words in the book omma lane...