I am trying to scrape some results from ebay with python and I am running into an error :
condition = item['condition'][0]['conditionDisplayName'][0] >>> KeyError: 'condition'` This is the code in question :
for item in (parseddoc["findItemsByKeywordsResponse"][0] ["searchResult"][0]["item"]): condition = item['condition'][0]['conditionDisplayName'][0] print(condition) I am trying to figure out a way to stop it from getting the error and just default to a preset value( "N/A" for example ) and continue with the loop. What's the best way to achieve that? Thanks
defaultdictcondition =in a try block and if exception is thrown change value to "N/A"