Python Program to Check if a Date is Valid or not

In this example, we will write a python program to take input date from the user and display whether it is valid or not. To better understand this example, make sure you have knowledge of the following tutorials:-

Let us have basic information about the valid dates:-

  • The month should be a number from 1 to 12
  • The maximum day in a month is fixed as
    • January, March, May, July,  August, October, December has 31 days
    • April, June, September, November has 30 days
    • February has 28 days (29 in leap years)
  • Leap year calculation is required to check the number of days for February

Python Program to Check if a Date is Valid or not

The output of the above program is:-

Enter year: 1990
Enter month: 03
Enter day: 09
Valid Date
SHARE Python Program to Check if a Date is Valid or not

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Share