[Tutor] Re: Calendar question
John Carmona
jeannot18 at hotmail.com
Wed Apr 6 14:12:39 CEST 2005
Thanks John for your help.
Here is the final script (and it is working)
------------------------------------------------------------------------------------------
import calendar
MonthName = {'January': 1,'February': 2, 'March': 3,'April': 4
,'May': 5,'June': 6,'July': 7,'August': 8,
'September': 9,'October': 10,'November': 11,'December': 12}
calendar.setfirstweekday(0)
##setfirstweekday change the day to what you want it be
## 0=Monday, 6=Sunday.
year = int(raw_input("Enter a year: "))
monthString = (raw_input("Enter a month: "))
while monthString not in MonthName:
print "Unknown month!"
monthString = raw_input('Enter a month: ')
month = MonthName[monthString]
print calendar.prmonth(year,month)
------------------------------------------------------------------------------------------
>##By the way do the number have to be under that format??
I don't understand the question, sorry..
This was a question for me, by that I meant would 01,02,03 etc format work
as well (And it does). Sorry for the confusion.
Now I have got another question raising from this script. Would it be
possible for the person doing the input to use either the months name in
writing and also in number?
Thanks again John
JC
More information about the Tutor
mailing list