All pastes #744235 Raw Edit

Someone

public text v1 · immutable
·published 2007-10-21 06:59 UTC
rendered paste body
Gburga = open('gburg.txt', "r")
from string import punctuation
def wordcount(Gburga):
    Gburgdict = {}
    for line in Gburga:
        lineList = line.split()
        for i in range(0, len(lineList)):
            lineList[i] = lineList[i].lower().strip(punctuation)
            count = 0
            if lineList[i] == "":
                continue
            else:
                if Gburgdict.has_key(lineList[i]):
                    Gburgdict[lineList[i]] += 1
                else:
                    Gburgdict[lineList[i]] = 1

            
    #sort
    GburgList = Gburgdict.items()
    GburgList.sort()

    newList = []
    for x,y in Gburgdict.items():
        newList.append( (y,x) )
    newList.sort(reverse = True)

    print GburgList
    print newList

wordcount(Gburga)