Text to A-Z Frequency Calculator

  • Share this:

Code introduction


Calculates and returns the frequency of each letter (a to z) in the given text.


Technology Stack : collections, string

Code Type : Function

Code Difficulty : Intermediate


                
                    
def a_to_z_frequency(text):
    from collections import Counter
    from string import ascii_lowercase
    
    frequency = Counter(text.lower())
    sorted_frequency = {char: frequency[char] for char in ascii_lowercase if char in frequency}
    
    return sorted_frequency