Created
December 16, 2009 21:14
-
-
Save gsiegman/258182 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
phone_char_mappings = { | |
'A': '2', 'B': '2', 'C': '2', | |
'D': '3', 'E': '3', 'F': '3', | |
'G': '4', 'H': '4', 'I': '4', | |
'J': '5', 'K': '5', 'L': '5', | |
'M': '6', 'N': '6', 'O': '6', | |
'P': '7', 'R': '7', 'S': '7', | |
'T': '8', 'U': '8', 'V': '8', | |
'W': '9', 'X': '9', 'Y': '9', | |
'1': '1', '2': '2', '3': '3', | |
'4': '4', '5': '5', '6': '6', | |
'7': '7', '8': '8', '9': '9', | |
'0': '0' | |
} | |
def alpha_phone_to_numeric(phone_number): | |
return "".join([_convert_phone_char(char) for char in list(phone_number)])[:10] | |
def _convert_phone_char(char): | |
if char in phone_char_mappings: | |
return phone_char_mappings[char] | |
else: | |
return '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment