letter frequency counter / your thoughts..
castironpi at gmail.com
castironpi at gmail.com
Wed May 7 15:04:49 EDT 2008
On May 7, 1:31 pm, "Ian Kelly" <ian.g.ke... at gmail.com> wrote:
> On Wed, May 7, 2008 at 11:30 AM, Paul Melis <p... at floorball-flamingos.nl> wrote:
> > dic = {}
> > for letter in strng:
> > if letter not in dic:
> > dic[letter] = 0
> > dic[letter] += 1
>
> As a further refinement, you could use the defaultdict class from the
> collections module:
>
> dic = defaultdict(int)
> for letter in strng:
> dic[letter] += 1
Sounds like novel flow of control.
More information about the Python-list
mailing list