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 =
This approach can be tried if you don't want to use any library and keep it simple and short!
a = [1,1,1,1,2,2,2,2,3,3,4,5,5] marked = [] b = [(a.count(i), marked.append(i))[0] for i in a if i not in marked] print(b)
o/p
[4, 4, 2, 1, 2]