Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
a small change in the original list solution in Clear category for Speech Module by pherapont
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):
n = [number//100, number%100//10, number%100%10]
hunderts = FIRST_TEN[n[0]] + HUNDRED if n[0]!= 0 else ""
decades = OTHER_TENS[n[1]]
units = FIRST_TEN[n[2]] if n[1] != 1 else SECOND_TEN[n[2]]
return "{}{}{}".format(hunderts, decades, units).rstrip()
June 29, 2019
Comments: