i need to write a function which receives a long string, and puts into a dictionary
each letter, and it's it's appearance frequency in the string.
iv'e written the next function, but the problem it doesn't ignore whitespaces, numbers etc..
iv'e been asked to use the function symbol in string.ascii_lowercase
, but iv'e no idea how to do it.
this is my code:
def calc_freq(txt):
dic={}
for letter in range(len(txt)):
if dic.has_key(txt[letter])==True:
dic[txt[letter]] += 1
else:
dic[txt[letter]] = 1
return dic
thanks for any help.