Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Python 3.8 rules! solution in Clear category for Speech Module by uaxz
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 x := number // 100:
res.append(f'{FIRST_TEN[x - 1]} {HUNDRED}')
number %= 100
if x := number // 10:
if x > 1:
res.append(f'{OTHER_TENS[x - 2]}')
number %= 10
else:
res.append(f'{SECOND_TEN[number % 10]}')
number = 0
if number:
res.append(FIRST_TEN[number - 1])
return ' '.join(res)
Dec. 15, 2019