Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Speech Module by kezikov.maxim
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):
res = ''
if number // 100:
res += '{} {} '.format(FIRST_TEN[number // 100 - 1], HUNDRED)
number %= 100
if number // 20:
res += OTHER_TENS[number // 10 - 2] + ' '
number %= 10
if number // 10:
res += SECOND_TEN[number % 10]
number = 0
if number:
res += FIRST_TEN[number - 1]
return res.strip()
Aug. 9, 2019