Using datetime.timedelta.min

Hi, I am doing the 11th question Finding The Shortest Session in Working With Dates And Times In Python Practice Problems. The question asked us to go through a list of lists that contains data of the starting and ending points of visiting sessions, and then find the shortest session.

The code I wrote is this:

The provided answer used a different method:

The results are different by a minute, and it seems to be about using datetime.timedelta.min vs using None as the placeholder. But I can’t figure out what’s wrong with my code…

Also, the answer used row = [int(x) for x in row] - what is this method called? I’m at the end of the intermediate python course on Dataquest and it hasn’t been mentioned, so guess I will have to google it. Thanks!


Three things:

  1. Please add this problem’s link to the original post.
  2. Please use text in code format to show the code. This will aid with not only readability, but also reproducing your results.
  3. About the method that was used in the answer. Are you talking about list comprehensions? I think it might by a mishap that we are not teaching this. Thank you for bringing it to our attention.