Ross wrote:
... Use get to write histogram more concisely. You should be able to
eliminate the if statement.

def histogram(s):
        d = dict()
        for c in s:
                d[c]= d.get(c,0)
        return d

This code returns a dictionary of all the letters to any string s I
give it but each corresponding value is incorrectly the default of 0.
What am I doing wrong?

How is this code supposed to count?

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to