Alphabet Position Difference Calculator

  • Share this:

Code introduction


Calculate the difference in positions of two letters in the English alphabet.


Technology Stack : Built-in libraries

Code Type : Function

Code Difficulty : Beginner


                
                    
def a_to_z_index(a, b):
    def index_of(char):
        return ord(char) - ord('a')
    return index_of(a) - index_of(b)