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
import calendar
calendar.isleap(year)
Example
Let's find out if 2023 is a leap year:
import calendar
res = calendar.isleap(2023)
print(res)
The result of the executed code:
False
Example
Now let's find out if 2020 is a leap year:
import calendar
res = calendar.isleap(2020)
print(res)
The result of the executed code:
True