Alphabet Position Converter Function

  • Share this:

Code introduction


This function converts all alphabetic characters in the input string to their positions in the alphabet (e.g., 'a' to 1, 'b' to 2, etc.).


Technology Stack : String manipulation

Code Type : Function

Code Difficulty : Beginner


                
                    
def a_to_z(input_string):
    result = {}
    for char in input_string:
        if char.isalpha():
            result[char] = ord(char) - ord('a') + 1
    return result