In this Article we will see how to write a program to display a calendar in python. There are different ways to write program for calendar. It depends on the developer’s logic to write the program. Here we will use the calendar module in python to display the calendar.
Import calendar module in python as below:
import calendar
I am using Google Colab to write the program. you can use any Editor.
import calendar
# Enter the month and year
year = int(input("Enter year in yyyy format: "))
month = int(input("Enter month in mm format: "))
# print the calendar
print(calendar.month(year,month))
After executing the code, it will ask year and month to enter and you will be able to see the calendar.
If entering year as 2021 and month December(12) the calendar will look as below