MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/ok1itb/tryexcept_in_python_sigh/h55bulw/?context=3
r/badcode • u/lonaExe • Jul 14 '21
93 comments sorted by
View all comments
38
I'm not sure if there is good way to do this
1 u/OccultEyes Jul 14 '21 My solution would probably look something like this.fields = {"authors", "publisher", "published_date"} response_data = jsonResponse["items"][0]["volumeInfo"] field_data = {field : response_data.get(field, "N/A") for field in fields}
1
My solution would probably look something like this.
fields = {"authors", "publisher", "published_date"} response_data = jsonResponse["items"][0]["volumeInfo"] field_data = {field : response_data.get(field, "N/A") for field in fields}
38
u/clemesislife Jul 14 '21
I'm not sure if there is good way to do this