get the values of dictionary out of list python -


i using googlemaps library measure distance between 2 points. here output. know how assign distance ('text': '1,271km') variable?

dic = {'rows': [{'elements': [{'distance': {'value': 1271380,                                             'text': '1,271 km'},                                'duration': {'value': 43350,                                             'text': '12 hours 3 mins'},                                'status': 'ok'}]}],        'status': 'ok',        'destination_addresses': ['new york, ny, usa'],        'origin_addresses': ['chicago, il, usa']} 

example:

for x in dic:      if x == 'distance':          var = x.values() 

i assume posted 1 row , 1 element, data might have more this.

this how can iterate , extract distance value, example:

>>> row in dic['rows']: ...   element in row['elements']: ...     text = element['distance']['text'] ...  >>> text '1,271 km'