SyntaxFix
Write A Post
Hire A Developer
Questions
This works for Python 2.6.6
a = ["a", "b", "a"] result = dict((i, a.count(i)) for i in a) print result
prints
{'a': 2, 'b': 1}