[Tutor] Letter Frequency Count.

Tesla Coil tescoil@rtpro.net
Sat, 08 Jan 2000 18:01:04 -0600

Thanks Doug.  Dictionaries are my least familiar type,
and I just gave up too early on using a for loop.  Got it
to work without, but wouldn't have won any prizes for
economy, nor did it result in the most favorable data
structures for further operations.

Reading the whole file in one gulp isn't a problem here;
test file was little over 1k, most would be much smaller.

Was necessary to change countDict to stringette, and
I'll need to crunch some numbers from wapcaplet... :) 

import sys, string
simpsons = string.uppercase
simpsons = list(simpsons)
emperor = sys.stdin.read()
emperor = string.upper(emperor)
stringette = {}

for individual in emperor:
    if individual in simpsons:
        if stringette.has_key(individual):
            stringette[individual] = stringette[individual] + 1
            stringette[individual] = 1

wapcaplet = stringette.values()

Thanks 'gain