📅  最后修改于: 2022-03-11 14:46:10.050000             🧑  作者: Mango
from collections import Counter
mylist = ['red','green','blue','red','orange','red','green']
counts = Counter(mylist)
for item, count in counts.items():
counts[item] /= 14
print(counts)
# Counter({'red': 0.21428571428571427, 'green': 0.14285714285714285,
# 'blue': 0.07142857142857142, 'orange': 0.07142857142857142})