So i'm not too sure how to proceed with this.
I want to replace 1
with one
, 2
with two
and so on.
I'm supposed to do this with a list.. but I'm not sure how to do so.
The user inputs a 10 digit number, which gets re-arranged into a phone number and then dashes are added in the appropriate areas.
I have completed the first two parts but can't figure out the conversion to words.
Edit** I am saying this is not a duplicate due to the fact that I was looking for a simple method to doing this. Every other thread I looked at contained coding beyond the level of understanding that I possess.
def makePhoneNums():
original = getNumber()
phone_num = fixPhoneNum(original)
phone_word = getWordForm(phone_num)
printPhoneNums(original, phone_num, phone_word)
def getNumber():
original = input("Input a 10 digit number: ")
while 10 != len(original) or original.isdecimal == False:
original = input("Error! Input a 10 digit number!: ")
print()
return original
def fixPhoneNum(original):
switched = original[-1] + original[5:9] + original[1:5] + original[0]
phone_num = switched[:3] + '-' + switched[3:6] + '-' + switched[6:]
return phone_num
def getWordForm(phone_num):
words = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven',
'eight', 'nine']
s = '0123456789'
telNum = ''
for i in range(len(s)):
telNum += words[int(s[i])]
return words[i]
def printPhoneNums(original, phone_num, phone_word):
print(original, '\t', phone_num, '\t ', phone_word)