Demo entry 6642046



Submitted by anonymous on Sep 22, 2017 at 01:35
Language: Python 3. Code size: 796 Bytes.

import string

s = 'Bach was the most famous composer in the world, and so was Handel. Handel was half German, half Italian and half English. He was very large. Bach died from 1750 to the present. Beethoven wrote music even though he was deaf. He was so deaf he wrote loud music. He took long walks in the forest even when everyone was calling for him. Beethoven expired in 1827 and later died for this.'
exclude = set(string.punctuation)
s = ''.join(ch for ch in s if ch not in exclude)
s = ''.join(i for i in s if not i.isdigit())
s= s.replace(" ", "").lower()
dic = {}
count = 0
for i in s:
    count +=1
    if i in dic.keys():
        dic[i] +=1
        dic[i] = 1
for k,v in dic.items():
    dic[k] =dic[k]/count

for k,v in dic.items():
    print (k,v)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).