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) |