GH avatar Bite 7. Parsing dates from logs

In this bite we will look at this small server log finding the first and last system shutdown events:

INFO 2014-07-03T23:27:51 supybot Shutdown initiated.
...
INFO 2014-07-03T23:31:22 supybot Shutdown initiated.

You need to calculate the time between these two events. First extract the timestamps from the log entries and convert them to datetime objects. Then use datetime.timedelta to calculate the time difference between them.

You can assume the logs are sorted in ascending order. Check out the docstrings and the TESTS for more info.

Good luck and keep calm and code in Python!

646 out of 795 users completed this Bite.
Will you be Pythonista #647 to crack this Bite?
It takes an average of ~77 minutes to solve this Bite (submissions 5-240 min).
Pythonistas rate this Bite 5.67 on a 1-10 difficulty scale.
» Up for a challenge? 💪

Login and get coding
We use Python 3.7