This is what I have to do :
On a standard telephone, the alphabetic letters are mapped
to numbers in the following fashion:
A, B, AND C=2
D, E, AND F=3
G, H, AND I=4
J, K, AND L=5
M, N, AND O=6
P, Q, R, AND S=7
T, U, AND V=8
W, X, Y AND Z=9
Write a program that asks the user to enter a 10-character
telephone numbers in the format
XXX-XXX-XXXX. The application should
display the telephone number with any alphabetic characters that appeared in
the original translated to their numeric
equivalent. For example, if the user enters 555-GET-FOOD the application should
display 555-438-3663.
def main():
digits = ["2", "3", "4", "5", "6", "7", "8", "9"]
numeric_phone=" "
phone_number = input('Enter 10-Digit phone number: ')
ch= digits[index]
for ch in phone_number:
if ch.isalpha():
if ch == 'A' or ch == 'B' or ch == 'C':
index = 0
if ch == 'D' or ch == 'E' or ch == 'F':
index = 1
if ch == 'G' or ch == 'H' or ch == 'I':
index = 2
if ch == 'J' or ch == 'K' or ch == 'L':
index = 3
if ch == 'M' or ch == 'N' or ch == 'O':
index = 4
if ch == 'P' or ch == 'Q' or ch == 'R' or ch == 'S':
index = 5
if ch == 'T' or ch == 'U' or ch == 'V':
index = 6
if ch == 'W' or ch == 'X' or ch == 'Y' or ch == 'Z':
index = 7
numeric_phone= numberic_phone+ch
print(numeric_phone)
This is what I have so far. Can anyone make suggestions or tell me what I need
to correct?
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor