list1 = [1,2,2,3,2,4,3,5,5,6]
dic1 = {}
for i,v in enumerate(list1):
if v not in dic1: # 如果数字不在哈希表中(字典的key)则次数为1
dic1[v] =1
else: # 把之前的次数+1
dic1[v] = dic1[v] + 1
print(dic1) # {1: 1, 2: 3, 3: 2, 4: 1, 5: 2, 6: 1}