You can download this code by clicking the button below.
This code is now available for download.
This function takes two arguments, a and b, and returns their indices in the English alphabet. If the arguments are not letters, it returns None.
Technology Stack : Dictionary comprehension, dictionary, string method lower(), get method
Code Type : Function
Code Difficulty : Beginner
def a_to_z_index(a, b):
return {chr(i): i - 96 for i in range(97, 123)}.get(a.lower(), None), {chr(i): i - 96 for i in range(97, 123)}.get(b.lower(), None)