from collections import defaultdict
L = ['a', 'b', 'a', 'b']
d = defaultdict(int)
for item in L:
    d[item] += 1
print(d)
print(list(d.items()))
Most Efficient way to calculate Frequency of values in a Python list?