Forgot to Reply-All. Dagnabbit. ---------- Forwarded message ---------- From: Kristian Zoerhoff <[EMAIL PROTECTED]> Date: Apr 5, 2005 3:33 PM Subject: Re: [Tutor] Calendar question To: John Carmona <[EMAIL PROTECTED]>
On Apr 5, 2005 3:08 PM, John Carmona <[EMAIL PROTECTED]> wrote: > Kristian you wrote: > > --------------------------------------------------------------------------------------------- > This assumes all input as integers; if you want months entered by > name, you'll have to write a conversion routine (hint: use a dict). > --------------------------------------------------------------------------------------------- > > I have been looking for a while about doing a conversion routine (using a > dictionary??), are you saying that I should convert a string (January, > February, etc.) into integers. Could you please give me some light (do not > write the code please but just point me to the right direction if you can) Create a dictionary whose keys are month names (lowercase, for simplicity), and whose values are integers. Get the month name from the user (don't convert to an int directly this time, but do convert to lowercase), then use that to get the appropriate integer value from the dictionary for passing to calendar.prmonth. It's really more of a lookup than a conversion. There are probably other ways to do this as well, but this will give you a nice introduction to using dictionaries in Python. -- Kristian kristian.zoerhoff(AT)gmail.com zoerhoff(AT)freeshell.org -- Kristian kristian.zoerhoff(AT)gmail.com zoerhoff(AT)freeshell.org _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor