Skip to content

Conversation

@omenshikh
Copy link

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!

omenshikh and others added 10 commits January 5, 2020 12:42
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant