Is there a shorter version of the current code for counting the occurrences if an element in an array and store it in a dictionary?
a = [1,2,2,3,4,5,2,2,1]
dic = {}
for x in a:
if x in dic:
dic[x] = dic[x] + 1
else:
dic[x] = 1
print dic