The program below needs some additional steps completed. The sample data is a nested dictionary. Your task is to fill
to extract the latitude ('lat'), longitude ('lng'), and formatted address. Note that extra sample data will be use to test wh
operates correctly on new data objects so make sure your program correctly references the function parameter.
# Problem 3
def extract_location(data):
# extract latitude, longitude and formatted address of the first matching location
# Fill in the blanks to make the code work
#### YOUR CODE - fill in the blanks ####
latitude = data['results'][0]['geometry']['location']['lat']
longitude = data['results'][0]['geometry']['location']['lng']
formatted_address = data['results'][0]['formatted_address']
# tests:
print("latitude:", latitude)
print("longitude:", longitude)
print("address:", formatted_address)
[144] # run this block to define the sample data
sample_data={"results":
[
{
"formatted_address": "121 Presidents Dr, Amherst, MA 01003, USA",
"geometry":{
"location": {
"lat":42.386697,
"lng":-72.52489299999999
},
"location_type": "ROOFTOP",