Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

CodeRace/20060105/Leonardong

From ZeroWiki
f = file("Alice.txt", 'r')
def cut(word):
    for mark in ,.'():;~=-?!`:
        word = word.replace(mark,"")
    return word

result = {}
for word in f.read().split():
    word = cut(word)
    if word in result.keys():
        result[word] +=1
    else:
        result[word] = 1

report = list()
for word, count in result.items():
    report.append((word, count))

report.sort()
def asciiSum(word):
    return 0

for each in report:
    print each[0], each[1], asciiSum(each[0])
f.close()