I am using the google maps api to reverse geocode latitude and longitudes on the map. I want to return the address in the following format: [street number] [route], [town], [state] with the brackets removed.
I am not sure how to link the address components to the types. Right now this is my solution but it doesn't always return the correctly formatted address. How can I search by type? Other solutions have used a loop but I am not sure what the if statements would look like?
address = '{} {}, {}, {}'.format(json['results'][0]['address_components'][0]['long_name']
, json['results'][0]['address_components'][1]['long_name']
, json['results'][0]['address_components'][3]['long_name']
, json['results'][0]['address_components'][5]['short_name'])