I'm trying to create a histogram in python
My fuction is the next one:
def hist_hor(diccionario):
dict={}
for e in diccionario:
if e in dict:
dict[e] += '*'
else:
dict[e]= '*'
for i in sorted(dict):
print(f'{i}: {dict[i]}')
histograma_horizontal(d)
It is supposed to look like this:
a: *****
b: **********
c: ************
d: ***********
e: ***************
f: ********************
g: ***************
h: *********
i: *******
j: **
but with my function it looks like this:
a: *
b: *
c: *
d: *
e: *
f: *
g: *
h: *
i: *
j: *
Besides, anyone who knows to represent it in that way too ?:
*
*
*
*
* * *
* * *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * * * * * *
* * * * * * * * * *
defaultdict.