Objective
Create a Python program that tells how many days a month has and whether the year is a leap year, using the calendar module.
Instructions
- Read an integer
nand thennlines with two integersyear month(the month goes from 1 to 12). - Use
calendar.monthrange(year, month)(the second value is the number of days) andcalendar.isleap(year). - Show
YYYY-MM: D days (leap year)orYYYY-MM: D days (non-leap year), with the month in two digits (for example2024-02).
3
2024 2
2026 2
2026 4
2024-02: 29 days (leap year)
2026-02: 28 days (non-leap year)
2026-04: 30 days (non-leap year)
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise