Identifying Missing Letters in a String

  • Share this:

Code introduction


This function takes a string as input, counts the occurrence of each letter in the string, and returns a list of letters that are not present in the string.


Technology Stack : collections.Counter, string

Code Type : Function

Code Difficulty : Intermediate


                
                    
def a_to_z_counter(string):
    from collections import Counter
    import string

    counter = Counter(string)
    alphabet = string.ascii_lowercase
    missing_letters = [char for char in alphabet if char not in counter]
    return missing_letters