from collections import Counter z = ['blue', 'red', 'blue', 'yellow', 'blue', 'red'] Counter(z) >>> Counter({'blue': 3, 'red': 2, 'yellow': 1})