Answers for "weather reporter with python"

2

weather reporter with python

import time
import requests
from pprint import pprint

try:
    
    Api_key = "Your api key"
    city_or_country = str(input('Write a "city" or "Country" name for which you want the weather:- '))
    print("Fetching Data of",city_or_country)
    time.sleep(4)
    URL = "https://api.openweathermap.org./data/2.5/weather?appid=" + Api_key + "&q="+ city_or_country
    weather_data = requests.get(URL).json()
    pprint(weather_data)
except ValueError:
    print("incorrect input or API KEY")
Posted by: Guest on June-25-2021

Python Answers by Framework

Browse Popular Code Answers by Language