dividing counter object in python

Solutions on MaxInterview for dividing counter object in python by the best coders in the world

showing results for - "dividing counter object in python"
Lindsay
26 Jun 2018
1from collections import Counter
2mylist = ['red','green','blue','red','orange','red','green']
3
4counts = Counter(mylist)
5for item, count in counts.items():
6    counts[item] /= 14
7
8print(counts)
9# Counter({'red': 0.21428571428571427, 'green': 0.14285714285714285, 
10# 'blue': 0.07142857142857142, 'orange': 0.07142857142857142})
11
similar questions
queries leading to this page
dividing counter object in python