Problem with a dictionary program....

Ling Lee janimal at mail.trillegaarden.dk
Tue Sep 28 09:28:19 EDT 2004


Hello.

I'm trying to write a small program that lets you put in a number as an 
integer and then it tells you the textuel representation of the number.

Like if your input is 42, it will say four two.

I found out that I have to make a dictionary like this: List = { 1:"one", 
2:"two" and so on )

and I have to use the raw_input method to get the number:

indput : raw_input(" Tell me the number you want to transform to textuel 
representaion")

The I have to transform the input to a string
indput = str(indput)

so that I can count how many decimals the number has, like 23 has 2 decimals 
and 3000 has 4 decimals.

After I have gotten the lenght of the string, I will write a loop, that goes 
through the dictionary as many times as the lengt of the string, and the 
gives me the corresponding numbers, the numner 21 would go 2 times through 
the loop and give me the output two one

Will one of you be so kind and tell me how I count the lengt of the indput 
number i was thinking on something like input.count[:] but that dosnt 
work...

 and how I make the loop.

 Im trying to understand dictionaries but have gotten a bit stuck...

Thanks for all replies....






More information about the Python-list mailing list