f = open("lrc.txt","r") lrc = f.read() f.close() a = (''',.?-''') for i in a: lrc = lrc.replace(i," ") lrc = lrc.lower() lrc = lrc.split() d = set(lrc) di = {} for i in d: di[i] = lrc.count(i) print(di) prep = {'oh','a'} for i in prep: del(di[i]) dic1 = sorted(di.items(),key=lambda d:d[1],reverse= True) print(dic1) for i in range(10): print(dic1[i])