# Problem with a dictionary program....

Neuruss luismg at gmx.net
Wed Sep 29 04:44:47 CEST 2004

```I¡ve got a program that already does what you want.
I don't remember the author, I got it somewhere on the net, but it
works great. It's in spanish but you'll get the idea...

if x == 0:
if x == 1:
if x == 2:
if x == 3:
if x == 4:
if x == 5:
if x == 6:
if x == 7:
if x == 8:
if x == 9:

def teens(x):
if x == 0:
teenname = "diez"
if x == 1:
teenname = "once"
if x == 2:
teenname = "doce"
if x == 3:
teenname = "trece"
if x == 4:
teenname = "catorce"
if x == 5:
teenname = "quince"
return teenname

def tens(x):
if x == 1:
tensname = "diez"
if x == 2:
tensname = "veinte"
if x == 3:
tensname = "treinta"
if x == 4:
tensname = "cuarenta"
if x == 5:
tensname = "cincuenta"
if x == 6:
tensname = "sesenta"
if x == 7:
tensname = "setenta"
if x == 8:
tensname = "ochenta"
if x == 9:
tensname = "noventa"
return tensname

def tercia(num):
numero=str(num)
if len(numero) == 1:
numero='00'+numero
if len(numero) == 2:
numero='0'+numero
a=int(numero[0])
b=int(numero[1])
c=int(numero[2])
#       print a, b, c
if a == 0:
if b == 0:
elif b == 1:
if c >= 0 and c <= 5:
elif c >= 6 and c <= 9:
elif b == 2:
if c == 0:
elif c > 0 and c <= 9:
elif b >=3 and b <= 9:
if c == 0:
if c >= 1 and c <= 9:
if a == 1:
if b == 0:
if c == 0:
elif c > 0 and c <= 9:
elif  b == 1:
if c >= 0 and c <= 5:
elif c >= 6 and c <= 9:
elif b == 2:
if c == 0:
elif c > 0 and c <= 9:
elif b >= 3 and b <= 9:
if c == 0:
elif c > 0 and c <= 9:
)

elif a >= 2 and a <= 9:
if a == 5:
prefix='quinientos '
elif a == 7:
prefix='setecientos '
elif a == 9:
prefix='novecientos '
else:
if b == 0:
if c == 0:
elif c > 0 and c <= 9:
elif b == 1:
if c >= 0 and c <= 5:
elif c >= 6 and c <= 9:
elif b == 2:
if c == 0:
elif c > 0 and c <= 9:
elif b >= 3 and b <= 9:
if c == 0:
elif c > 0 and c <= 9:
def main(num):
result=''
numero=str(num)
if len(numero) == 1:
numero='00000000'+numero
if len(numero) == 2:
numero='0000000'+numero
if len(numero) == 3:
numero='000000'+numero
if len(numero) == 4:
numero='00000'+numero
if len(numero) == 5:
numero='0000'+numero
if len(numero) == 6:
numero='000'+numero
if len(numero) == 7:
numero='00'+numero
if len(numero) == 8:
numero='0'+numero
posicion=1
for i in [0,3,6]:
var=numero[i]+numero[i+1]+numero[i+2]
if int(var) != 0:
res=tercia(var)
if i == 0:
result=res+" millones "
elif i == 3:
result=result+res+" mil "
elif i == 6:
result=result+res
return result

```