import requests

api_key = "298b96c84db46086182d7d5265bc7272"

GetCity = input("Podaj miasto bez polskich znaków: ")

def check_coordinates(city):
    response = requests.get(f"http://api.openweathermap.org/geo/1.0/direct?q={city}&appid={api_key}")

    if(response.status_code == 200):
        lat = response.json()[0]['lat']
        lon = response.json()[0]['lon']
        return [lat,lon] 
    else:
        print(response.status_code)
        return []
    
def check_weather(lat,lon):
    response = requests.get(f"http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&limit=1&appid={api_key}")

    if(response.status_code == 200):
        print(response.json()["weather"][0]["description"])
    else:
        print(response.status_code)
        return
    
coordinates = check_coordinates(GetCity)
check_weather(coordinates[0], coordinates[1])
