Path: blob/master/12-Advanced Python Modules/08-Advanced-Python-Module-Exercise/08-Advanced-Modules-Exercise-Solutions.ipynb
666 views
Advanced Modules Exercise Solutions
It's time to test your new skills, this puzzle project will combine multiple skills sets, including unzipping files with Python, using os module to automatically search through lots of files.
Your Goal
This is a puzzle, so we don't want to give you too much guidance and instead have you figure out things on your own.
There is a .zip file called 'unzip_me_for_instructions.zip', unzip it, open the .txt file with Python, read the instructions and see if you can figure out what you need to do!
If you get stuck or don't know where to start, here is a guide/hints
Step 1: Unzipping the File
We can easily use the shutil library to extract and unzip the contents of the .zip file
Step 2: Read the instructions file
Let's figure out what we need to do, open the instructions.txt file.
Step 3: Regular Expression to Find the Link
There are many approaches to take here, but since we know we are looking for a phone number, there should be a digits in the form ###-###-####, so we can easily create a regex expression for this and test it. Once its tested and working, we can figure out how to run it through all the txt documents.
Step 4: Create a function for regex
Let's put this inside a function that applies it to the contents of a .txt file, this way we can apply this function to all the txt files in the extracted_content folder.
Step 5: OS Walk through the Files to Get the Link
Now that we have a basic function to search through the text of the files, let's perform an os.walk through the unzipped directory to find the links hidden somewhere in one of the text files.
Excellent work! More information on this phone number: