Computer >> Computer tutorials >  >> Programming >> Python

How to check if a year is a leap year using Python?


not a leapyear using Python. The calender module has a special function, isleap(year), that returns True if year is a leap year, otherwise it returns False.

Example

import calendar
print(calendar.isleap(1995))
print(calendar.isleap(2008))
print(calendar.isleap(2004))

Output

This will give the output −

False
True
True