2009 109: Difference between revisions
(New page: http://www.danos.nl/teog) |
No edit summary |
||
Line 1: | Line 1: | ||
http://www.danos.nl/teog | http://www.danos.nl/teog | ||
In-class, doing Exercise | |||
<source lang="python"> | |||
def histogram(s): | |||
d = dict() | |||
for c in s: | |||
if c not in d: | |||
d[c] = 1 | |||
else: | |||
d[c] += 1 | |||
return d | |||
</source> |
Revision as of 12:52, 9 December 2008
In-class, doing Exercise
def histogram(s):
d = dict()
for c in s:
if c not in d:
d[c] = 1
else:
d[c] += 1
return d