4 ms·
You are right about your implementation. I was thinking about the Pythons collections.defaultdict from collections import defaultdict s = 'mississippi' d = d
by europa 12y ago
You are right about your implementation. I was thinking about the Pythons collections.defaultdict
from collections import defaultdict
s = 'mississippi'
d = defaultdict(int)
for k in s:
d[k] += 1
d.items()
[('i', 4), ('p', 2), ('s', 4), ('m', 1)]
- ghshephard 12y agoThe difference here - is that you are actually assigning a value to the dictionary element. It's the assignment that's growing the dictionary, not the query.