Frequency of Letter in String || Dictionary || Python
In this we are going to see a basic program to find the frequency of letter in a string and store them in a dictionary in Python Programming Language.



def count_letters(text):
    result = {}
    for letter in text:
        if letter not in result:
            result[letter] = 0
        result[letter] += 1

    return result

print(count_letters("AABBCCDD"))

# Coded by Shreya Idate


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post