Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
n % 100, n // 100, n % 10 solution in Creative category for Speech Module by flpo
from itertools import chain
TWENTY = [
'', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight',
'nine', 'ten', 'eleven', 'twelve', 'thirteen','fourteen', 'fifteen',
'sixteen', 'seventeen', 'eighteen', 'nineteen'
]
TENS = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
N = dict(chain(enumerate(TWENTY), zip(range(20, 91, 10), TENS)))
def checkio(n):
n, h, u = n % 100, n // 100, n % 10
return (f'{N[h]} hundred ' * (h>0) + N.get(n, f'{N[n-u]} {N[u]}')).strip()
Jan. 10, 2018
Comments: