← TechnologyThe essentials of

Calendar: finding the number of days in a month

Publisher: ResumeMaker • 1 source

Published: 22 Oct 2026 16:11 · Updated: 22 Oct 2026 16:11

AI source check: 22 Oct 2026 14:04. This is not editorial approval.

In a few sentences

In brief

calendar.monthrange(2024, 2) returns the weekday of the first day and the number of days in the month. The second result is 29 for that February.

Useful to know

calendar.monthrange(2024, 2) returns the weekday of the first day and the number of days in the month. The second result is 29 for that February. [1]

This helps build a calendar without maintaining a separate leap-year table. The first result uses Monday as zero. Do not confuse it with a day-of-month number or an automatically localized label.

Sources

For further detail and to check the information:

  1. [1] calendar — General calendar-related functions — Python 3.12.15 documentation ↗