Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
long concatenate solution in Creative category for Speech Module by sanello
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):
h, d, u = number//100, number%100//10, number%10
return (f'{FIRST_TEN[h - 1]} hundred' * (1 if h else 0) + f' {OTHER_TENS[d - 2]}' * (1 if d > 1 else 0) + f' {SECOND_TEN[u]}' * (1 if d == 1 else 0) + f' {FIRST_TEN[u - 1]}' * (1 if d != 1 and u else 0)).lstrip()
Aug. 29, 2019
Comments: