Hey If you are beginner and want to learn a python then you are on right path. Learn basic as well as advanced programming in Python.

Search

Python program to check whether entered date is valid or not.

PYTHON PROGRAM




date=input("Enter date in format(dd/mm/yyyy):-")

day,month,year=date.split('/')

day=int(day)

month=int(month)

year=int(year)

if month==1 or month==3 or month==5 or month==7 or 
month==8 or month==8 or month==10 or month==12:

max_day=31

elif month==4 or month==6 or month==9 or month==11:
max_day=30

elif year%4==0:

max_day=29

else:

max_day=28

if month<1 or month>12:

print (day,"/",month,"/",year,"date is invalid")

print ("\n**kindly,Check range of month**")

elif day<1 or day>max_day:

print (day,"/",month,"/",year,"date is invalid")

print("**Kindly check range of days**")

else:

print ("**Entered  date is valid**")







*** Input && Output ***
















No comments:

Post a Comment

let me know which type examples you want to comment me.