Apple interview question

Python parsing a text file according to the requirements