ross.jett at gmail.com
Tue Dec 30 02:38:36 CET 2008
On Dec 29, 8:07 pm, Scott David Daniels <Scott.Dani... at Acm.Org> wrote:
> 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... at Acm.Org
I realize the code isn't counting, but how am I to do this without
using an if statement as the problem instructs?
More information about the Python-list