You can download this code by clicking the button below.
This code is now available for download.
This function converts all alphabetic characters in the input string to their corresponding positions in the English alphabet, while leaving non-alphabetic characters unchanged.
Technology Stack : String processing
Code Type : String conversion function
Code Difficulty : Intermediate
def a_to_z_converter(string):
alphabet = 'abcdefghijklmnopqrstuvwxyz'
converted = ''
for char in string.lower():
if char.isalpha():
converted += alphabet[ord(char) - ord('a')]
else:
converted += char
return converted