Enter the city name to know the weather
We are going to get the weather of a city using OpenWeatherMap API. To use the OpenWeatherMap API, we have to get the API key. We will get it by creating an account on their website. We need requests module for the HTTP requests and JSON module to work with the response. Follow the below steps to get the weather of any city:
->Import the requests and JSON modules.
->Initialize the base URL of the weather API.
->Initialize the city and API key.
->Update the base URL with the API key and city name.
->Send a get request using the requests.get() method.
->And extract the weather info using the JSON module from the response.