The isleap method of the calendar module
The isleap method of the calendar module determines whether the specified year is a leap year. The method returns True or False. In the method parameter, we specify the year we are interested in.
Syntax
pythonimport calendar
calendar.isleap(year)
Example
Let's find out if 2023 is a leap year:
pythonimport calendar
res = calendar.isleap(2023)
print(res)
The result of the executed code:
pythonFalse
Example
Now let's find out if 2020 is a leap year:
pythonimport calendar
res = calendar.isleap(2020)
print(res)
The result of the executed code:
pythonTrue