Im trying to write a program that inputs a single letter and prints out the corresponding digit on the telephone. Im having trouble finding out a way in which you can group the variables that have the same digit, but im not sure how. You guys have any suggestions? P.S. im running python 3.2.2
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
Q = 7
R = 7
S = 7
T = 8
U = 8
V = 8
W = 9
X= 9
Y = 9
Z = 9
digit = ""
UserInput = str(input("Enter a single letter, and I will tell you what the correrponding digit on the telephone:"))
if UserInput == A or B or C:
digit = "2"
print("The digit",digit,"corresponds to the letter", UserInput, "on the telephone.")
elif UserInput == D or E or F:
digit = "3"
print("The digit",digit,"corresponds to the letter", UserInput, "on the telephone.")
elif UserInput == G or H or I:
digit = "4"
print("The digit",digit,"corresponds to the letter", UserInput, "on the telephone.")
elif UserInput == J or K or L:
digit = "5"
print("The digit",digit,"corresponds to the letter", UserInput, "on the telephone.")
elif UserInput == M or N or O:
digit = "6"
print("The digit",digit,"corresponds to the letter", UserInput, "on the telephone.")
elif UserInput == P or Q or R or S:
digit = "7"
print("The digit",digit,"corresponds to the letter", UserInput, "on the telephone.")
elif UserInput == T or U or V:
digit = "8"
print("The digit",digit,"corresponds to the letter", UserInput, "on the telephone.")
elif UserInput == W or X or Y or Z:
digit = "9"
print("The digit",digit,"corresponds to the letter", UserInput, "on the telephone.")
else :
print("There is no digit on the telephone that corresponds to",UserInput)