0

I am counting occurences of names and want to display them with how often they occured:

from collections import Counter

data = ["Bob", "Bob", "Sally", "Tom", "Bob", 
        "Tom", "Evan", "Sally", "Evan", "Evan"]

c = Counter(data)

for key, value in c.items():
    print(key + "\t      " + str(value))

this gives me

Bob           3
Sally         2
Tom           2
Evan          3

But I want

Bob           ***
Sally         **
Tom           **
Evan          ***

How to do it?

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69

0 Answers0