I need to find the frequency of elements in an unordered list
a = [1,1,1,1,2,2,2,2,3,3,4,5,5]
output->
b =
In Python 2.7+, you could use collections.Counter to count items
>>> a = [1,1,1,1,2,2,2,2,3,3,4,5,5] >>> >>> from collections import Counter >>> c=Counter(a) >>> >>> c.values() [4, 4, 2, 1, 2] >>> >>> c.keys() [1, 2, 3, 4, 5]