Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Speech Module solution in Clear category for Speech Module by HeyTech
FIRST_TEN = ["one", "two", "three", "four", "five", "six", "seven",
"eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "seventeen", "eighteen", "nineteen"]
OTHER_TENS = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy",
"eighty", "ninety"]
HUNDRED = "hundred"
def checkio(number):
StringArray = []
dif = number - (number//100)*100
if 0 < dif < 20:
StringArray.insert(len(StringArray), str(FIRST_TEN[dif-1]))
if 20 <= dif < 100:
if (dif-dif//10*10) > 0:
StringArray.insert(0, str(FIRST_TEN[dif-dif//10*10 -1]))
StringArray.insert(0, str(OTHER_TENS[dif//10-2]))
if number >= 100:
StringArray.insert(0, HUNDRED)
StringArray.insert(0, str(FIRST_TEN[(number-dif)//100-1]))
return " ".join(StringArray)
Nov. 3, 2015
Comments: