Is date correct?


date = "2/29/2017" dateSplit = date.split("/") isDateValid = True daysInMonth = [31,29,31,30,31,30,31,31,30,31,30,31] while isDateValid == True: inputMonth = int (dateSplit[0]) inputDays = int (dateSplit[1]) inputYear = int (dateSplit[2]) if (inputMonth == 2 and inputYear % 4 != 0 and inputDays == 29): isDateValid = False if (inputMonth > 0 and inputMonth <=12): pass; else: isDateValid = False if (inputYear >= 0): pass; else: isDateValid = False if (inputDays <= daysInMonth[inputMonth-1]): pass; else: isDateValid = False if (isDateValid == True): print ("The date provided is valid.") else: print ("The date provided is not valid.")

Loading Please Wait...