Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Speech Module by wbl4126
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):
rstr = []
if number > 99:
rstr += [FIRST_TEN[number//100-1]] + [HUNDRED]
if number % 100 > 19:
rstr += [OTHER_TENS[number%100//10-2]]
if 9 < number % 100 < 20:
rstr += [SECOND_TEN[number%10]]
elif number % 10:
rstr += [FIRST_TEN[number%10-1]]
return ' '.join(rstr)
March 25, 2020