On 10/31/2013 7:52 AM, Carmen Salcedo wrote:
I'm not able to post it right now. All I did to the previous program i
emailed was changed isalpha() to str.isalpha.
That does agree with what you posted or got.
The part of your original program that should print a character already is
print (str.isalpha()
which raises this exception:
File "N:\Script2.py", line 37, in phoneTranslator
print(str.isalpha())
TypeError: descriptor 'isalpha' of 'str' object needs an argument
it should be
print n
Exactly what did you type in response to
phoneNumber = raw_input ("Please enter the phone number: ")
Note you are not consistent in converting letters:
elif n == "G" or n == "H" or n == "I":
n = "4"
elif n == "J" or n == "K" or n == "L":
n = 5
all the numbers should be characters e.g.
n = "5"
etc.
There are many ways to get the desired output.
One is:
collect the characters in one list, say numberList
Then use slicing to insert the "-" e.g. numberList[3:3] = "-"
Then print "".join(numberList)
--
Bob Gailer
919-636-4239
Chapel Hill NC
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor