r/badcode • • Jul 14 '21

python Try/Except in Python - Sigh

Post image
662 Upvotes

93 comments sorted by

View all comments

Show parent comment

51

u/DragonFireCK Jul 14 '21

For that to work with this structure, it would be jsonResponse.get("items", {}).get(0, {}).get("volumeInfo",{}).get("authors, "N/A")

Now, as the first block is repeated for all the entries, and it should be pulled out which would simplify the code a lot.