Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple solution solution in Clear category for Speech Module by ludek.reif
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):
result = []
hundreds = number // 100
tens = (number - hundreds * 100) // 10
units = number - (hundreds * 100 + tens * 10)
if hundreds:
result.append(FIRST_TEN[hundreds - 1])
result.append(HUNDRED)
if tens == 0:
if units != 0:
result.append(FIRST_TEN[units - 1])
else: pass
elif tens == 1:
result.append(SECOND_TEN[units])
else:
result.append(OTHER_TENS[tens - 2])
if units != 0:
result.append(FIRST_TEN[units - 1])
return " ".join(result)
Feb. 1, 2016