Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Speech Module by tokiojapan55
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):
if number < 10:
return FIRST_TEN[number - 1]
if number < 20:
return SECOND_TEN[number - 10]
if number < 100:
result = OTHER_TENS[(number // 10) - 2]
if number % 10 != 0:
result += " " + FIRST_TEN[(number % 10) - 1]
return result
result = FIRST_TEN[(number // 100) - 1] + " " + HUNDRED
if number % 100 != 0:
result += " " + checkio(number % 100)
return result
June 17, 2020