On 03/20/2013 01:09 AM, Mitya Sirenef wrote:
By the way, you can further simplify it by doing: def histogram2(s): return {c: d.get(c,0)+1 for c in s} That will work in python 3, in python 2 you need: return dict((c: d.get(c,0)+1) for c in s)
Sorry, it should use a comma: return dict((c, d.get(c,0)+1) for c in s) -m -- Lark's Tongue Guide to Python: http://lightbird.net/larks/ _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor