On this page
calendar.leapdays
Prev: calendar.isleap | Up: calendar | Next: calendar.LocaleHTMLCalendar
Rel: calendar.calendar, calendar.Calendar, calendar.Day, calendar.firstweekday
Ref: docs.python.org — calendar.leapdays
Tags: #public #python3 #stdlib #calendar
Import
import calendar
from calendar import leapdays
Signature & Overview
calendar.leapdays(y1, y2)
Return number of leap years in range [y1, y2).
Usage
import calendar
# Half-open range [y1, y2): includes y1, excludes y2
assert calendar.leapdays(2020, 2025) == 2 # 2020 and 2024
Gotchas
- Exclusive upper bound
y2:leapdays(2020, 2024)returns1, not2.
REPL Inspect
from calendar import leapdays
help(leapdays)
Linked from
Related notes
- tuts/python3/stdlib_module/calendar/isleap Linked here; links to this page; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/LocaleHTMLCalendar Linked here; links to this page; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/calendar Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/Calendar_class Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/Day Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/firstweekday Linked here; shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/calendar/HTMLCalendar shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/IllegalMonthError shared tags: #calendar, #stdlib
- tuts/python3/stdlib_module/calendar/IllegalWeekdayError shared tags: #calendar, #stdlib