Count Frequency Of Each Element in Array using Python

collections.Counter function

import collections

data = [10, 'test', 'test', 10, 'Hi', 'test']
result = dict(collections.Counter(data))

print(result)

Leave a Comment

Cancel reply

Your email address will not be published.