I have a list with 0
, 1
and 2
,
I want to create a dict with the count of each.
This is my code,
count_map = {}
for i in my_list:
if i in count_map:
count_map[i] += 1
else:
count_map[i] = 1
My question is how can I write this code more pythonically.