139 of 151 menu

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

See also

  • method today of module datetime,
    which returns the current date
  • method now of module datetime,
    which returns the current time
  • method date of module datetime,
    which creates a new object with a date
enru