I want to do the following with less code:
if "address" in structured_data:
if "addressCountry" in structured_data["address"]:
data["country"] = structured_data["address"]["addressCountry"]
Is this possible?
I want to do the following with less code:
if "address" in structured_data:
if "addressCountry" in structured_data["address"]:
data["country"] = structured_data["address"]["addressCountry"]
Is this possible?
What about using a try
?
try:
data["country"] = structured_data['address']['addressCountry']
except KeyError:
pass # handle what you want to do