Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Modification of the initial lists solution in Clear category for Speech Module by sacerg
#Modification of the list, so I can use directly them directly
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):
chaine = ""
if number // 100 > 0:
chaine += FIRST_TEN[number // 100] + " " + "hundred" + " "
if 10 <= number % 100 < 20:
chaine += SECOND_TEN[number % 100 - 10]
else:
chaine += OTHER_TENS[(number % 100) // 10] + " " + FIRST_TEN[number % 10]
chaine = chaine.replace(" ", " ")
return chaine.strip()
Oct. 27, 2015