python string freqeuncy code example
Example 1: freq count in python
freq = {}
for item in my_list:
if (item in freq):
freq[item] += 1
else:
freq[item] = 1
Example 2: python codes for counting the occurrence of a letters in dictionary excluding digits
def count_letters(text):
result = {}
for letter in text:
if letter not in result:
result[letter.lower()] = 1
else:
result[letter.lower()] += 1
return result
print(count_letters("AaBbCc"))
print(count_letters("Math is fun! 2+2=4"))
print(count_letters("This is a sentence."))