Counting elements with dictionary Posted by kracekumar on Wednesday February 26, 2014 @02:10PM from the kracekumar.com dept. http://kracekumar.com/post/77925927684/counting-elements-with-dictionary ( 1 comment | 2 points | on HN )
In modern Python (starting with Python 2.7, released in 2010), the Pythonic solution is collections.Counter:
or dict(Counter(words)) if you want the result to return an actual dict instead of a Counter instance.