I am trying to get a code to return true if the start date is before or the same as the end date. However, I am unable to get the correct output for some testing cases.
def difference(start_day, start_mon, start_year, end_day, end_mon, end_year):
start_date = (start_day, start_mon, start_year)
end_date = (end_day, end_mon, end_year)
if start_date <= end_date:
return True
else:
return False
***My output:***
difference(19, 3, 2014, 19, 3, 2014) #True
difference(18, 3, 2014, 19, 3, 2014) #True
difference(20, 3, 2014, 19, 3, 2014) #False
difference(19, 3, 2015, 19, 3, 2014) #False
difference(19, 6, 2014, 19, 3, 2014) #False
difference(18, 12, 2014, 19, 11, 2014) #True <- This is the wrong output
difference(18, 12, 2014, 19, 11, 2015) #True
***Expected output:***
difference(19, 3, 2014, 19, 3, 2014) #True
difference(18, 3, 2014, 19, 3, 2014) #True
difference(20, 3, 2014, 19, 3, 2014) #False
difference(19, 3, 2015, 19, 3, 2014) #False
difference(19, 6, 2014, 19, 3, 2014) #False
difference(18, 12, 2014, 19, 11, 2014) #False
difference(18, 12, 2014, 19, 11, 2015) #True
I tried different ways of writing the code but I am still unable to obtain the expected output for all the test cases.