Counting up (a.k.a. tallying up) the items in iterables in ruby and python
In python 2 and 3
from collections import Counter
Counter('dennislibre')
# Counter({'e': 2, 'n': 2, 'i': 2, 'd': 1, 's': 1, 'l': 1, 'b': 1, 'r': 1})
In ruby (added in version 2.7.0)
'dennislibre'.split('').tally
=> {"d"=>1, "e"=>2, "n"=>2, "i"=>2, "s"=>1, "l"=>1, "b"=>1, "r"=>1}