-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chapter 17. hn_submissions.py, KeyError #100
Comments
Hi, there's an update for the second edition that addresses this: https://ehmatthes.github.io/pcc_2e/updates/sixth_printing/#chapter-17 |
I ran into the same issue while working on Chapter 17. Luckily, I came across your message; otherwise, I'd still be stuck. By the way, when I was using try-except-else, I referenced {submission_id} to pinpoint which wretched ID caused the error - it was 36924518! Hahahaha! |
i encounter the same situation, thanks for your solution |
Hello!
Working with the Hacker News API i've catched a keyerror in the first 'for' loop.
But the key 'descendants' was actually in dictonary.
I checked every single literal (not literally, but nearby :) ). The code was exactly like in the book.
After time i've decided to try to decrease submission_ids from [:30] to [:10]. The error was magically disappeared. By increasing of the quantity submission_ids back to [:30] i found out, that one of thirty really dont have the key 'descendants'.
As i understand, its a problem of an API response, but it would be nice to add the way to handle the cases when some data in the API response is missing.
PS. So far i checked, nobody pushed that issue. Sorry, if someone did.
The text was updated successfully, but these errors were encountered: