Home / Python / Example programs / Useful mini-programs

Python program: Print a monthly calendar

Print the calendar for a month with the calendar module.

The code

import calendar

print(calendar.month(2026, 12))
cal = calendar.Calendar()
fridays = [d for d in cal.itermonthdates(2026, 12) if d.month == 12 and d.weekday() == 4]
print("Fridays:", [d.day for d in fridays])

Output

   December 2026
Mo Tu We Th Fr Sa Su
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31

Fridays: [4, 11, 18, 25]

How it works

The calendar module formats months and years, and can list the dates of a month for your own calculations.

Learn the ideas behind it in the free lesson Modules & the Standard Library.