[Tutor] Re: Calendar question

John Carmona jeannot18 at hotmail.com
Wed Apr 6 18:58:39 CEST 2005


Kristian you have said:
---------------------------------------------------------------------------------------------------------
I can think of 2 ways to accomplish this.

1. Try to convert monthString to an int, use the lookup if that fails.
This might be a good way to learn try/except processing.

2. Just double-up your dictionary to include a second set of keys:

{'1':1, '2':2 ...}

and just use your existing lookup method, unmodified. You wouldn't
have to worry about string->int conversion after raw_input this way,
so it's cleaner to implement.
-------------------------------------------------------------------------------------------------------------
When you say to double-up the dictionary do you mean using the following 
method:

Dict = [{1:1,2:4,etc.},
{3:9,4:16, etc}]

Thanks JC




More information about the Tutor mailing list