We use Python 3.6

go back Level: Intermediate (img: IM / score: 3) level Bite 7. Parsing dates from logs

360 out of 437 users completed this Bite ...
Will you be Pythonista #361 to crack this Bite?
Average Bite difficulty 1-10 rating: 5.82
» Up for a challenge? 💪

In this bite we will look at this small server log finding the first and last Shutdown initiated events and calculate the time between the two events.

In order to do this you need to extract the timestamps from the log entries and convert them to datetime objects. You can then use datetime.timedelta to calculate time differences between them. Check out the docstrings and the TESTS for more info.

Good luck and have fun!

Update 4th of Apr 2018: we slightly updated the Bite to make it a bit more intuitive. We removed the requirement to read in the file. If you already started this Bite and the tests break, click on LAST SAVES -> START OVER to load in the new template code.

Github login button