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 ''
- Getting user input from the keyboard
- Python’s time.sleep() – Pause, Stop, Wait or Sleep your Python Code
- Using Python to Display Calendars | Learn How to Print a Calendar in Python with Example
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.