Re:LINQ Ruined My Favorite Interview Question
by wiredfool on Thursday July 11, 2013 @02:23PM
(#6028030)
Or, use a defaultdict(int), or more in line with yours:
d[word] = d.get(word,0) + 1
dictionary.get is quite useful.
Also, I'd consider s.split(None), instead of s.split(' '). It will group whitespace, so that any double space or other whitespace is collapsed into one delimiter.
d[word] = d.get(word,0) + 1
dictionary.get is quite useful.
Also, I'd consider s.split(None), instead of s.split(' '). It will group whitespace, so that any double space or other whitespace is collapsed into one delimiter.