Month length depends on both the month and the year. Ask the calendar rather than maintaining a table with a special February branch.
Worked example
import calendar
print(calendar.monthrange(2026, 2)[1])Result
28Implementation notes
Calendar rules depend on which calendar is being modeled. Use a date or calendar primitive throughout, and defer localized month names to display.
Try it yourself
Check February 2000 against February 2100.
Open the Python example →Editorial date September 27, 2025 · Published December 6, 2026