""" Just the main ideas from word_count.py """ # find a way to get a list of the words from # file, let's say they're in a really big list # called words = ['moby', 'dick', 'by, 'herman', ...] # count for each word of how many times it show up count = {} for word in words: count[word] = 1 + count.get(word, 0) # Now count is e.g. {'moby':5234, 'the':122234, 'lorax':1, ...} # To sort by count, I want to create list of pairs: # [ [5234,'moby'], [122234,'the'], [1,'lorax':1], ... ] pairs = [] for key in count.keys(): # key='moby', 'the', ... pairs.append( [ count[key] , key ] )