I think this results to the same as Triptych's solution, but without importing collections. Also a bit like Selinap's solution, but more readable imho. Almost identical to Thomas Weigel's solution, but without using Exceptions.

This could be slower than using defaultdict() from the collections library however. Since the value is fetched, incremented and then assigned again. Instead of just incremented. However using += might do just the same internally.

splitting by a space is redundant. Also, you should use the dict.set_default method instead of the try/except.
– TriptychMay 21 '09 at 17:05

2

It's a lot slower because you are using Exceptions. Exceptions are very costly in almost any language. Avoid using them for logic branches. Look at my solution for an almost identical method, but without using Exceptions: stackoverflow.com/questions/893417/…
– hoplaJun 11 '09 at 20:30