I'm trying to create a program that takes in text from a file and outputs the frequency of each letter. The output also shows the frequency of '.' but I only want to output the frequency of letters. I'm trying to use isalpha() but I'm not sure where to put it. This is my code so far:
def count(str):
d = dict()
word = str.lower()
for i in word:
for j in i:
if j in d:
d[j] = d[j] + 1
else:
d[j] = 1
return d
print(count("Once upon a time there lived a princess who was too beautiful and kind to her subjects. The poets and artists were all in praise of her beauty and their works were inspired by her. Once a charming prince from another kingdom came to meet the princess and soon they became friends and slowly they fell in love"))
I tried putting isalpha() here:
for i in word.isalpha():
but it just gives me an error.