To display calendar in python, you have to ask from user to enter year and month to print the calendar of that year and month as shown here in the program given below.
Following python program ask from user to enter year and month to display calendar:
# Python Program - Display Calendar import calendar while True: print("Enter 'x' for exit.") y = input("Enter Year: ") m = input("Enter month: ") if y == 'x': break else: yy = int(y) mm = int(m) print("\n",calendar.month(yy,mm))
Here is the sample run of the above Python program illustrating how to display or print calendar of given year and month: