I am using the following code to get frequency of letters in a text:
for s in 'abcdefghijklmnopqrstuvwxyz ':
count = 0
for char in rawpunct.lower():
if s == char:
count +=1
result = s, '%.3f' % (count*100/len(rawpunct.lower()))
f_list.append(result)
And the result is :
['0.061', '0.012', '0.017', '0.030', '0.093', '0.016', '0.016',
'0.049', '0.050', '0.001', '0.006', '0.034', '0.018', '0.052', '0.055',
'0.013', '0.001', '0.041', '0.050', '0.069', '0.021', '0.007', '0.017',
'0.001', '0.013', '0.000', '0.159']
but I want to store the cumulative frequencies, i.e create this list :
['0.061', '0.073', '0.100', '0.130' ............ ]
Anyone know how to do this?
Just for the fun of the one-liner :