import requests
from pprint import pprint

key = "6192adb7d770604e34121efcd96f664d"

def check_cocordinatata(city, key):
    print("=======================")
    x = requests.get(f"http://api.openweathermap.org/geo/1.0/direct?q={city},&appid={key}")

    lat = x.json()[0]["lat"]
    lon = x.json()[0]["lon"]

    y = requests.get(f"https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={key}")

    temperature = y.json()["main"]["temp"] - 273.15 #kelvin - celcius
    pressure = y.json()["main"]["pressure"]
    humidity = y.json()["main"]["humidity"]
    weather = y.json()["weather"][0]["description"]

    print(str(x.json()[0]["name"]) + ", " + str(x.json()[0]["country"])) #data

    print("=======================")
    print("latitude: "+ str(round(lat, 2)))
    print("longtitude: " + str(round(lon, 2)))
    print(f"temperature: {str(round(temperature, 2))}°C")
    print(f"pressure: {str(pressure)} hPa")
    print(f"humidity: {str(humidity)}%")
    print(f"weather: {weather}")
    print("=======================")

a = input("Enter in your city: ")
check_cocordinatata(a, key)