On Wed, May 7, 2008 at 11:30 AM, Paul Melis <[EMAIL PROTECTED]> 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 -- http://mail.python.org/mailman/listinfo/python-list