Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Simple solution in Clear category for Speech Module by slickLash
FIRST = {0:'', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine'}
FIRST.update({10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'})
TENS = {20: 'twenty', 30: 'thirty', 40: 'forty', 50: 'fifty', 60: 'sixty', 70: 'seventy', 80: 'eighty', 90: 'ninety'}
def checkio(number):
result = []
if number > 99:
result.append(FIRST[number // 100] + ' hundred')
number %= 100
if number < 20:
result.append(FIRST[number])
else:
div, mod = divmod(number, 10)
result.append(TENS[div * 10])
if mod:
result.append(FIRST[mod])
return ' '.join(result).rstrip()
March 1, 2015
Comments: