I'm taking Udacity's Intro to Computer Science course and one of the quizzes had me create a function that takes in two dates and checks whether the first date is before the second. I first wrote the function with nested if statements, but then I began to experiment and came up with this:
def dateCheck(year1, month1, day1, year2, month2, day2):
date1 = year1, month1, day1
date2 = year2, month2, day2
if date1 < date2:
return True
else:
return False
To my surprise, it worked perfectly. Can someone please explain to me why this works? I'm guessing it has something to do with tuples (which haven't been covered yet).
Aucun commentaire:
Enregistrer un commentaire