Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Speedy category for Speech Module by McTpaxep
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):
num = [int(x) for x in str(number)][::-1]
ans = ' ' + FIRST_TEN[num[0]-1] if num[0] != 0 else ''
if len(num) > 1 and num[1] == 1:
ans = ' ' + SECOND_TEN[num[0]]
if len(num) > 1 and 0 != num[1] != 1 :
ans = ' ' +OTHER_TENS[num[1]-2] + ans
if len(num) > 2:
ans = FIRST_TEN[num[2]-1] + ' ' + HUNDRED + ans
return ans.strip()
Oct. 5, 2014
Comments: