Q:

How to count occurrence of items in a list in Python?

lets say: 
 a = [1,1,2,2,3,3,3,3,4,4,4,4] 

b is dict  
I want b as dict which represents number of occurrence of items in a:
I want jinja2 template that create output as below.  
Output of b should be,  ( key - itemName, Value - corresponding item occurrence in list)  
1 : 2  
2 : 2  
3 : 4  
4 : 4  

Is it possible to do via jinja2 template - i have jinja engine which renders some output i want to add this kind of stuff in template.

A:

count_dict = {i:a.count(i) for i in set(a)}

is that what you asked for?

