SaveText.Ru

Кто южнее?
  1. import requests
  2.  
  3. mas = input().split(',')
  4. ans = []
  5.  
  6. for i in range(len(mas)):
  7.     geocoder_request = "http://geocode-maps.yandex.ru/1.x/?apikey=40d1649f-0493-4b70-98ba-98533de7710b&geocode=" + mas[
  8.         i] + "&format=json"
  9.     response = requests.get(geocoder_request)
  10.  
  11.     if response:
  12.         json_response = response.json()
  13.         toponym = json_response["response"]["GeoObjectCollection"]["featureMember"][0]["GeoObject"]
  14.         ans.append((mas[i], float(toponym['Point']['pos'].split()[1])))
  15.     else:
  16.         print("Ошибка выполнения запроса:")
  17.         print(geocoder_request)
  18.         print("Http статус:", response.status_code, "(", response.reason, ")")
  19.  
  20. ans.sort(key=lambda x: x[1])
  21. print(ans[0][0])

Share with your friends:

Print