Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Clear? solution in Clear category for Speech Module by kskkskksk
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):
digit_list = list(map(int, [digit for digit in str(number)]))
output = []
if len(digit_list) == 3:
output.append(FIRST_TEN[digit_list[0]-1])
output.append(HUNDRED)
if number >= 20 and digit_list[-2] >= 2:
output.append(OTHER_TENS[digit_list[-2]-2])
if number >= 10 and digit_list[-2] == 1:
output.append(SECOND_TEN[digit_list[-1]])
if number <= 9 or digit_list[-2] != 1 and digit_list[-1] != 0:
output.append(FIRST_TEN[digit_list[-1]-1])
return " ".join(output)
April 18, 2015