At 07:44 AM 8/6/2007, Kent Johnson wrote: >Dick Moores wrote: >>Gotta say though, I still don't understand how the defaultdict works here. > >Did you try the docs? >http://docs.python.org/lib/defaultdict-objects.html
Yes, but it left me still in the dark. >If coinCount were an ordinary dict, the line > coinCount[deno] += 1 > >would have to be written as > coinCount[deno] = coinCount.get(deno, 0) + 1 > >Using defaultdict(int) makes the use of 0 as the default value >automatic. (Actually the default value is obtained by calling int(), >whose value is 0.) OK, thanks for spelling it out, Kent. Dick _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor