On Apr 6, 2005 11:58 AM, John Carmona <[EMAIL PROTECTED]> wrote:
> 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}]
You're close, but a list of dicts is overkill here; stick to one big
dict, and leave the keys as strings, so you can just grab data from
raw_input directly, and do something like this:
Months = {'january':1, '1':1, 'february':2, '2':2, 'march':3, '3':3 .....}
Essentially double the number of keys in the dictionary. It's a bit
redundant, but you'll be able to then just grab
>>>month = raw_input("Enter a month: ")
>>>Months[month]
with no string->int conversion; the dict does it all for you, just as
it does in your code now.
--
Kristian
kristian.zoerhoff(AT)gmail.com
zoerhoff(AT)freeshell.org
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor