Solution to the Python API Challenge#4
Open
omenshikh wants to merge 10 commits intogadventures:masterfrom
Open
Solution to the Python API Challenge#4omenshikh wants to merge 10 commits intogadventures:masterfrom
omenshikh wants to merge 10 commits intogadventures:masterfrom
Conversation
My approach to solving this problem I have broken the challenge into some smaller tasks: 1. How to collect all departures from the API 2. How to filter them down by the start date and category 3. How to create a CSV file containing only filtered departures And tried to google my way through each of them. - The first function is checking to make sure that the status code of the HTTP response is the only acceptable code of 200, and otherwise is printing an error explaining to the user what exactly went wrong. Then it’s checking the “results” part and appending all results to the list of departures, then checking for the next page, and so on using the for loop; - The second function is filtering departures and returning a filtered list; - The third function writes a CSV file with field names as per instructions; - The if __name__ function is there to condense all of my calls in one place, in case if there happen to be another app with imported solution. I’ve added a couple comments inside solution.py file with links to some helpful resources for my personal use, but in addition to googling how to do a certain operation, I’ve also completed a few courses on programming foundations in LinkedIn learning to better understand some concepts. Since you’ve mentioned that I could use any resources available to me, once I had the initial draft completed, I showed it to Ben who has helped me with making migration, and also helped me find and fix an indentation error in my solution.py file that would make my app crash. This challenge has taken me a lot longer than suggested 4 hours, but it works, and it’s all I could ask for. It also prompted me to learn so much more to get it done, so I’m grateful for this opportunity to challenge myself.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here is my approach to solving the Python API Challenge. In the "README updated" file you will find a detailed explanation about the solution. Thank you for the learning opportunity, it was fun!