Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Speech Module by grazik
FIRST_TEN = ["one", "two", "three", "four", "five", "six", "seven",
"eight", "nine"]
SECOND_TEN = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "seventeen", "eighteen", "nineteen"]
TENS = ["ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy",
"eighty", "ninety"]
HUNDRED = "hundred"
def checkio(n):
result = ''
if n > 99:
result += FIRST_TEN[n//100 - 1] + ' ' + HUNDRED
n %= 100
if n > 19:
result += ' ' + TENS[n//10 - 1]
if n%10 > 0:
n %= 10
result += ' ' + FIRST_TEN[n-1]
elif n > 9:
result += ' ' + SECOND_TEN[n-10]
elif n > 0:
result += ' ' + FIRST_TEN[n-1]
return result.lstrip(' ')
Oct. 31, 2016