Write is_valid_date(year, month, day) that returns True if the three numbers form a real calendar date and False otherwise. The month must be 1 to 12 and the day must be between 1 and the number of days in that month. February has 29 days in a leap year and 28 otherwise; a year is a leap year if it is divisible by 4, except that years divisible by 100 are not leap years unless they are also divisible by 400.
Examples
Input: year = 2024, month = 2, day = 29
Output: True
Input: year = 2023, month = 2, day = 29
Output: False
Input: year = 2021, month = 4, day = 31
Output: False
Constraints
1 <= year <= 9999monthanddayare integers (possibly out of range)
Goals
- Work out how many days a month has, including February in leap years
- Combine several validity rules into one boolean answer