Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Speech Module by m600
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):
letters = []
if number / 100 > 0:
letters.append(FIRST_TEN[number / 100 - 1])
letters.append(HUNDRED)
if 9 < number % 100 < 20:
letters.append(SECOND_TEN[(number % 100) % 10])
if number % 100 > 19:
letters.append(OTHER_TENS[(number % 100) / 10 - 2])
if not 9 < number % 100 < 20 and number % 100 % 10 > 0:
letters.append(FIRST_TEN[number % 100 % 10 - 1])
return " ".join(item for item in letters)
June 18, 2015
Comments: