Problem with a dictionary program....

Alex Martelli aleaxit at yahoo.com
Tue Sep 28 11:47:29 EDT 2004


Ling Lee <janimal at mail.trillegaarden.dk> wrote:
   ...
> List =
> {1:"one",2:"two",3:"three",4:"four",5:"five",6:"six",7:"seven",8:"eight",9
> :"nine"}

You're missing 0, so an input such as 103 would give an error even if
all the rest of your code was correct.

> output = []
> for character in indput:
>   output.append(List[character])
>   print ', '.join(output)

This will print N times when you have N digits... outdent the print
statement so it's executed after the 'for' and not inside it.


Alex



More information about the Python-list mailing list