f = open('/usr/share/dict/words') l = f.readlines() def zlicz_dl(l): d = {} for i in l: n = len(i) if n in d: d[n] += 1 else: d[n] = 1 return d def druk(d): nmax = 75 dzielnik = max(d.values())/nmax for key in d: print('{}: {}'.format(str(key).rjust(3), '*'*int(d[key]/dzielnik))) d = zlicz_dl(l) druk(d)