I have this programme here that counts how many times a word was used in my .txt file and displays the top 10 most common words. I am hoping to display this information without the numbers as well though, so just the words. Any help would be greatly appreciated.
def countWordFrequency(Data1):
myDict = {}
fh = open(Data1, 'r')
content = fh.read()
listWords = content.split(" ")
for w in listWords:
if (myDict.has_key(w)):
myDict[w] = myDict[w] + 1
else:
myDict[w] = 1
fh.close()
return myDict
freq = countWordFrequency('Data1.txt')
topfreq = sorted(freq.iteritems(), key=lambda x:-x[1])[:10]
for x in topfreq:
print "{0}: {1}".format(*x)