Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Speech Module by saklar13
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 = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy",
"eighty", "ninety"]
HUNDRED = "hundred"
def checkio(number):
result = []
if number//100:
result.extend([FIRST_TEN[number//100 -1], HUNDRED])
number %= 100
if number > 19:
result.append(OTHER_TENS[number // 10 - 2])
number %= 10
if 10 <= number < 20:
result.append(SECOND_TEN[number % 10])
if 0 < number < 10:
result.append(FIRST_TEN[number - 1])
return ' '.join(result)
Dec. 25, 2014