How to get the total number of leap days in the years within range in Python?

PythonServer Side ProgrammingProgramming

The Python calendar library has a function exactly for finding the total number of leap days in the years within range. The calender.leapdays(y1, y2) returns the total number of leap days in the years within range(y1,y2).

For example

import calendar
print(calendar.leapdays(1995, 2018))

Output

This will give the output −

6
raja
Published on 08-Jan-2018 08:18:09
Advertisements