Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Uncategorized category for Speech Module by Pouf
FIRST_TEN = ["", "one", "two", "three", "four", "five", "six", "seven",
"eight", "nine"]
SECOND_TEN = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "seventeen", "eighteen", "nineteen"]
OTHER_TENS = ["", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy",
"eighty", "ninety"]
def checkio(intNum):
strNum = str(intNum)
spokenNum = []
if intNum > 99:
spokenNum.append(FIRST_TEN[int(strNum[0])])
spokenNum.append('hundred')
strNum = strNum[1:]
if 9 < int(strNum) < 20:
spokenNum.append(SECOND_TEN[int(strNum[1])])
return ' '.join(spokenNum).strip()
elif int(strNum) > 19 :
spokenNum.append(OTHER_TENS[int(strNum[0])])
strNum = strNum[1:]
if len(strNum) == 2: strNum = strNum[1:]
spokenNum.append(FIRST_TEN[int(strNum[0])])
return ' '.join(spokenNum).strip()
March 12, 2014