Python Display Calendar

This script will ask for an input of a year. It will then take that input and return the calendar for that entire year.

import calendar

print "Show a given years monthly calendar"

print ''

year = int(raw_input("Enter the year"))

print ''

calendar.prcal(year)

print ''

Try another year by adding a while loop into the script.

import calendar

while True:
    print "Show a given years monthly calendar"
 
    print ''
 
    year = int(raw_input("Enter the year"))
 
    print ''
 
    calendar.prcal(year)
 
    print ''
 
    raw_input("Press enter to go on ...")

For more things to do with the calendar module, please see the official documentation.

Leave a Reply

Your email address will not be published. Required fields are marked *