File size: 439 Bytes
1787bf2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import requests

def get_the_weather_forecast(city_name):
    url = 'https://wttr.in/{}'.format(city_name)
    try:
        data = requests.get(url)
        weather_forecast = data.text
    except:
        weather_forecast = "Error Occurred"
    return(weather_forecast)

if __name__ == "__main__":
    city_name = input("Enter the name of the city: ")
    weather_forecast = get_the_weather_forecast(city_name)
    print(weather_forecast)