Owibundu / API-weather

API weather
0 stars 0 forks source link

Cannot find mistake for Bratislava #1

Open Owibundu opened 2 months ago

Owibundu commented 2 months ago

python import requests api_key = "d9134214c33559f346979ed3aebffc5b" city = "Bratislava" url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric" response = requests.get(url) if response.status_code == 200: data = response.json() temperature = data["main"]["temp"] weather = data["weather"][0]["description"] print(f"The current temperature in {city} is {temperature}°C with {weather}.") else: print(f"Error: Unable to fetch data. Status code {response.status_code}")

Owibundu commented 2 months ago

import requests api_key = "832884c988ccc5a0f6521ee6e5049301" city = "Bratislava" url = f"http://api.openweathermap.org/data/2.5/weather?q={city}&appid={api_key}&units=metric" response = requests.get(url) if response.status_code == 200: data = response.json() temperature = data["main"]["temp"] weather = data["weather"][0]["description"] print(f"The current temperature in {city} is {temperature}°C with {weather}.") else: print('Error fetching weather data')