Hasten num_to_word

the return value when readable=False, but readable=False is never actually passed in the code
This commit is contained in:
Gouvernathor 2023-11-11 20:54:11 +01:00
parent f179095287
commit 20fcacf97b

View File

@ -26,7 +26,7 @@ init python early:
tens = ("","ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety") tens = ("","ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety")
thousands = ("","thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","decillion","undecillion","duodecillion","tredecillion","quattuordecillion","sexdecillion","septendecillion","octodecillion","novemdecillion","vigintillion") thousands = ("","thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","decillion","undecillion","duodecillion","tredecillion","quattuordecillion","sexdecillion","septendecillion","octodecillion","novemdecillion","vigintillion")
output = [] output = [] # list of iterables of strings (reminder that strings are iterables of strings)
if n == 0: if n == 0:
output.append("zero") output.append("zero")
else: else:
@ -39,10 +39,10 @@ init python early:
g = groups-(i//3+1) g = groups-(i//3+1)
if h > 0: if h > 0:
output.append(units[h]+" hundred") output.append((units[h], " hundred"))
if t > 1: if t > 1:
if u > 0: if u > 0:
output.append(tens[t]+"-"+units[u]) output.append((tens[t], "-", units[u]))
else: else:
output.append(tens[t]) output.append(tens[t])
elif t == 1: elif t == 1:
@ -56,12 +56,12 @@ init python early:
if g > 0 and (h+t+u) > 0: if g > 0 and (h+t+u) > 0:
if i == (groups*3)-6: if i == (groups*3)-6:
output.append(thousands[g]+" and") output.append((thousands[g], " and"))
else: else:
output.append(thousands[g]+",") output.append((thousands[g], ","))
if readable: if readable:
output = " ".join(output) output = " ".join("".join(o) for o in output)
return output return output
def clamp(n, smallest, largest): def clamp(n, smallest, largest):